@@ -308,58 +308,128 @@ void main() {
308308 });
309309
310310 group ('URL Construction' , () {
311- test ('should update legacy prod host to new host' , () {
312- const inputUrl = 'https://blah.supabase.co/storage/v1' ;
313- const expectedUrl = 'https://blah.storage.supabase.co/v1' ;
314- client = SupabaseStorageClient (inputUrl, {
315- 'Authorization' : 'Bearer $supabaseKey ' ,
311+ group ('default behavior (useNewHostname: false)' , () {
312+ test ('should NOT transform legacy prod host by default' , () {
313+ const inputUrl = 'https://blah.supabase.co/storage/v1' ;
314+ client = SupabaseStorageClient (inputUrl, {
315+ 'Authorization' : 'Bearer $supabaseKey ' ,
316+ });
317+ expect (client.url, inputUrl);
316318 });
317- expect (client.url, expectedUrl);
318- });
319319
320- test ('should update legacy staging host to new host' , () {
321- const inputUrl = 'https://blah.supabase.red/storage/v1' ;
322- const expectedUrl = 'https://blah.storage.supabase.red/v1' ;
323- client = SupabaseStorageClient (inputUrl, {
324- 'Authorization' : 'Bearer $supabaseKey ' ,
320+ test ('should NOT transform legacy staging host by default' , () {
321+ const inputUrl = 'https://blah.supabase.red/storage/v1' ;
322+ client = SupabaseStorageClient (inputUrl, {
323+ 'Authorization' : 'Bearer $supabaseKey ' ,
324+ });
325+ expect (client.url, inputUrl);
325326 });
326- expect (client.url, expectedUrl);
327- });
328327
329- test ('should accept new host without modification' , () {
330- const inputUrl = 'https://blah.storage.supabase.co/v1' ;
331- const expectedUrl = 'https://blah.storage.supabase.co/v1' ;
332- client = SupabaseStorageClient (inputUrl, {
333- 'Authorization' : 'Bearer $supabaseKey ' ,
328+ test ('should NOT transform legacy supabase.in host by default' , () {
329+ const inputUrl = 'https://blah.supabase.in/storage/v1' ;
330+ client = SupabaseStorageClient (inputUrl, {
331+ 'Authorization' : 'Bearer $supabaseKey ' ,
332+ });
333+ expect (client.url, inputUrl);
334334 });
335- expect (client.url, expectedUrl);
336- });
337335
338- test ('should not modify non-platform hosts' , () {
339- const inputUrl = 'https://blah.supabase.co.example.com/storage/v1' ;
340- const expectedUrl = 'https://blah.supabase.co.example.com/storage/v1' ;
341- client = SupabaseStorageClient (inputUrl, {
342- 'Authorization' : 'Bearer $supabaseKey ' ,
336+ test ('should accept new host without modification' , () {
337+ const inputUrl = 'https://blah.storage.supabase.co/v1' ;
338+ client = SupabaseStorageClient (inputUrl, {
339+ 'Authorization' : 'Bearer $supabaseKey ' ,
340+ });
341+ expect (client.url, inputUrl);
343342 });
344- expect (client.url, expectedUrl);
345- });
346343
347- test ('should support local host with port without modification' , () {
348- const inputUrl = 'http://localhost:1234/storage/v1' ;
349- const expectedUrl = 'http://localhost:1234/storage/v1' ;
350- client = SupabaseStorageClient (inputUrl, {
351- 'Authorization' : 'Bearer $supabaseKey ' ,
344+ test ('should not modify non-platform hosts' , () {
345+ const inputUrl = 'https://blah.supabase.co.example.com/storage/v1' ;
346+ client = SupabaseStorageClient (inputUrl, {
347+ 'Authorization' : 'Bearer $supabaseKey ' ,
348+ });
349+ expect (client.url, inputUrl);
350+ });
351+
352+ test ('should support local host with port without modification' , () {
353+ const inputUrl = 'http://localhost:1234/storage/v1' ;
354+ client = SupabaseStorageClient (inputUrl, {
355+ 'Authorization' : 'Bearer $supabaseKey ' ,
356+ });
357+ expect (client.url, inputUrl);
352358 });
353- expect (client.url, expectedUrl);
354359 });
355360
356- test ('should update legacy supabase.in host to new host' , () {
357- const inputUrl = 'https://blah.supabase.in/storage/v1' ;
358- const expectedUrl = 'https://blah.storage.supabase.in/v1' ;
359- client = SupabaseStorageClient (inputUrl, {
360- 'Authorization' : 'Bearer $supabaseKey ' ,
361+ group ('opt-in behavior (useNewHostname: true)' , () {
362+ test ('should update legacy prod host to new host' , () {
363+ const inputUrl = 'https://blah.supabase.co/storage/v1' ;
364+ const expectedUrl = 'https://blah.storage.supabase.co/v1' ;
365+ client = SupabaseStorageClient (
366+ inputUrl,
367+ {
368+ 'Authorization' : 'Bearer $supabaseKey ' ,
369+ },
370+ useNewHostname: true );
371+ expect (client.url, expectedUrl);
372+ });
373+
374+ test ('should update legacy staging host to new host' , () {
375+ const inputUrl = 'https://blah.supabase.red/storage/v1' ;
376+ const expectedUrl = 'https://blah.storage.supabase.red/v1' ;
377+ client = SupabaseStorageClient (
378+ inputUrl,
379+ {
380+ 'Authorization' : 'Bearer $supabaseKey ' ,
381+ },
382+ useNewHostname: true );
383+ expect (client.url, expectedUrl);
384+ });
385+
386+ test ('should accept new host without modification' , () {
387+ const inputUrl = 'https://blah.storage.supabase.co/v1' ;
388+ const expectedUrl = 'https://blah.storage.supabase.co/v1' ;
389+ client = SupabaseStorageClient (
390+ inputUrl,
391+ {
392+ 'Authorization' : 'Bearer $supabaseKey ' ,
393+ },
394+ useNewHostname: true );
395+ expect (client.url, expectedUrl);
396+ });
397+
398+ test ('should not modify non-platform hosts' , () {
399+ const inputUrl = 'https://blah.supabase.co.example.com/storage/v1' ;
400+ const expectedUrl = 'https://blah.supabase.co.example.com/storage/v1' ;
401+ client = SupabaseStorageClient (
402+ inputUrl,
403+ {
404+ 'Authorization' : 'Bearer $supabaseKey ' ,
405+ },
406+ useNewHostname: true );
407+ expect (client.url, expectedUrl);
408+ });
409+
410+ test ('should support local host with port without modification' , () {
411+ const inputUrl = 'http://localhost:1234/storage/v1' ;
412+ const expectedUrl = 'http://localhost:1234/storage/v1' ;
413+ client = SupabaseStorageClient (
414+ inputUrl,
415+ {
416+ 'Authorization' : 'Bearer $supabaseKey ' ,
417+ },
418+ useNewHostname: true );
419+ expect (client.url, expectedUrl);
420+ });
421+
422+ test ('should update legacy supabase.in host to new host' , () {
423+ const inputUrl = 'https://blah.supabase.in/storage/v1' ;
424+ const expectedUrl = 'https://blah.storage.supabase.in/v1' ;
425+ client = SupabaseStorageClient (
426+ inputUrl,
427+ {
428+ 'Authorization' : 'Bearer $supabaseKey ' ,
429+ },
430+ useNewHostname: true );
431+ expect (client.url, expectedUrl);
361432 });
362- expect (client.url, expectedUrl);
363433 });
364434 });
365435}
0 commit comments