@@ -151,6 +151,60 @@ describe('parseUrlString', () => {
151151        } 
152152      ) 
153153    } ) 
154+ 
155+     it ( 'can parse URL with CID+queryString where query string has providers' ,  async  ( )  =>  { 
156+       const  providers  =  [ 
157+         '/dns4/provider-server.io/tcp/443/https' , 
158+         '/dns4/provider-server.io/tcp/8000' 
159+       ] 
160+       await  assertMatchUrl ( 
161+         `ipfs://QmdmQXB2mzChmMeKY47C43LxUdg1NDJ5MWcKMKxDu7RgQm?format=tar&provider=${ providers [ 0 ] }  &provider=${ providers [ 1 ] }  ` ,  { 
162+           protocol : 'ipfs' , 
163+           cid : 'QmdmQXB2mzChmMeKY47C43LxUdg1NDJ5MWcKMKxDu7RgQm' , 
164+           path : '' , 
165+           query : { 
166+             format : 'tar' , 
167+             provider : providers 
168+           } 
169+         } 
170+       ) 
171+     } ) 
172+ 
173+     it ( 'can parse URL with CID+path+queryString where query string has providers' ,  async  ( )  =>  { 
174+       const  providers  =  [ 
175+         '/dns4/provider-server.io/tcp/443/https' , 
176+         '/dns4/provider-server.io/tcp/8000' 
177+       ] 
178+       await  assertMatchUrl ( 
179+         `ipfs://QmdmQXB2mzChmMeKY47C43LxUdg1NDJ5MWcKMKxDu7RgQm/1 - Barrel - Part 1/1 - Barrel - Part 1 - alt.txt?format=tar&provider=${ providers [ 0 ] }  &provider=${ providers [ 1 ] }  ` ,  { 
180+           protocol : 'ipfs' , 
181+           cid : 'QmdmQXB2mzChmMeKY47C43LxUdg1NDJ5MWcKMKxDu7RgQm' , 
182+           path : '1 - Barrel - Part 1/1 - Barrel - Part 1 - alt.txt' , 
183+           query : { 
184+             format : 'tar' , 
185+             provider : providers 
186+           } 
187+         } 
188+       ) 
189+     } ) 
190+ 
191+     it ( 'can parse URL with CID+queryString where query string has providers, but one is not valid' ,  async  ( )  =>  { 
192+       const  providers  =  [ 
193+         '/dns4/provider-server.io/tcp/443/https' , 
194+         'not-a-multiaddr' 
195+       ] 
196+       await  assertMatchUrl ( 
197+         `ipfs://QmdmQXB2mzChmMeKY47C43LxUdg1NDJ5MWcKMKxDu7RgQm?format=tar&provider=${ providers [ 0 ] }  &provider=${ providers [ 1 ] }  ` ,  { 
198+           protocol : 'ipfs' , 
199+           cid : 'QmdmQXB2mzChmMeKY47C43LxUdg1NDJ5MWcKMKxDu7RgQm' , 
200+           path : '' , 
201+           query : { 
202+             format : 'tar' , 
203+             provider : [ providers [ 0 ] ] 
204+           } 
205+         } 
206+       ) 
207+     } ) 
154208  } ) 
155209
156210  describe ( 'ipns://<dnsLinkDomain> URLs' ,  ( )  =>  { 
@@ -357,6 +411,42 @@ describe('parseUrlString', () => {
357411        } 
358412      ) 
359413    } ) 
414+ 
415+     it ( 'can parse an IPFS path with CID+queryString where query string has providers' ,  async  ( )  =>  { 
416+       const  providers  =  [ 
417+         '/dns4/provider-server.io/tcp/443/https' , 
418+         '/dns4/provider-server.io/tcp/8000' 
419+       ] 
420+       await  assertMatchUrl ( 
421+         `/ipfs/QmdmQXB2mzChmMeKY47C43LxUdg1NDJ5MWcKMKxDu7RgQm?format=tar&provider=${ providers [ 0 ] }  &provider=${ providers [ 1 ] }  ` ,  { 
422+           protocol : 'ipfs' , 
423+           cid : 'QmdmQXB2mzChmMeKY47C43LxUdg1NDJ5MWcKMKxDu7RgQm' , 
424+           path : '' , 
425+           query : { 
426+             format : 'tar' , 
427+             provider : providers 
428+           } 
429+         } 
430+       ) 
431+     } ) 
432+ 
433+     it ( 'can parse an IPFS path with CID+path+queryString where query string has providers' ,  async  ( )  =>  { 
434+       const  providers  =  [ 
435+         '/dns4/provider-server.io/tcp/443/https' , 
436+         '/dns4/provider-server.io/tcp/8000' 
437+       ] 
438+       await  assertMatchUrl ( 
439+         `/ipfs/QmdmQXB2mzChmMeKY47C43LxUdg1NDJ5MWcKMKxDu7RgQm/1 - Barrel - Part 1/1 - Barrel - Part 1 - alt.txt?format=tar&provider=${ providers [ 0 ] }  &provider=${ providers [ 1 ] }  ` ,  { 
440+           protocol : 'ipfs' , 
441+           cid : 'QmdmQXB2mzChmMeKY47C43LxUdg1NDJ5MWcKMKxDu7RgQm' , 
442+           path : '1 - Barrel - Part 1/1 - Barrel - Part 1 - alt.txt' , 
443+           query : { 
444+             format : 'tar' , 
445+             provider : providers 
446+           } 
447+         } 
448+       ) 
449+     } ) 
360450  } ) 
361451
362452  describe ( 'http://example.com/ipfs/<CID> URLs' ,  ( )  =>  { 
@@ -407,6 +497,42 @@ describe('parseUrlString', () => {
407497        } 
408498      ) 
409499    } ) 
500+ 
501+     it ( 'can parse an IPFS Gateway URL with CID+queryString where query string has providers' ,  async  ( )  =>  { 
502+       const  providers  =  [ 
503+         '/dns4/provider-server.io/tcp/443/https' , 
504+         '/dns4/provider-server.io/tcp/8000' 
505+       ] 
506+       await  assertMatchUrl ( 
507+         `http://example.com/ipfs/QmdmQXB2mzChmMeKY47C43LxUdg1NDJ5MWcKMKxDu7RgQm?format=tar&provider=${ providers [ 0 ] }  &provider=${ providers [ 1 ] }  ` ,  { 
508+           protocol : 'ipfs' , 
509+           cid : 'QmdmQXB2mzChmMeKY47C43LxUdg1NDJ5MWcKMKxDu7RgQm' , 
510+           path : '' , 
511+           query : { 
512+             format : 'tar' , 
513+             provider : providers 
514+           } 
515+         } 
516+       ) 
517+     } ) 
518+ 
519+     it ( 'can parse an IPFS Gateway URL with CID+path+queryString where query string has providers' ,  async  ( )  =>  { 
520+       const  providers  =  [ 
521+         '/dns4/provider-server.io/tcp/443/https' , 
522+         '/dns4/provider-server.io/tcp/8000' 
523+       ] 
524+       await  assertMatchUrl ( 
525+         `http://example.com/ipfs/QmdmQXB2mzChmMeKY47C43LxUdg1NDJ5MWcKMKxDu7RgQm/1 - Barrel - Part 1/1 - Barrel - Part 1 - alt.txt?format=tar&provider=${ providers [ 0 ] }  &provider=${ providers [ 1 ] }  ` ,  { 
526+           protocol : 'ipfs' , 
527+           cid : 'QmdmQXB2mzChmMeKY47C43LxUdg1NDJ5MWcKMKxDu7RgQm' , 
528+           path : '1 - Barrel - Part 1/1 - Barrel - Part 1 - alt.txt' , 
529+           query : { 
530+             format : 'tar' , 
531+             provider : providers 
532+           } 
533+         } 
534+       ) 
535+     } ) 
410536  } ) 
411537
412538  describe ( 'http://<CID>.ipfs.example.com URLs' ,  ( )  =>  { 
@@ -457,6 +583,42 @@ describe('parseUrlString', () => {
457583        } 
458584      ) 
459585    } ) 
586+ 
587+     it ( 'can parse an IPFS Subdomain Gateway URL with CID+queryString where query string has providers' ,  async  ( )  =>  { 
588+       const  providers  =  [ 
589+         '/dns4/provider-server.io/tcp/443/https' , 
590+         '/dns4/provider-server.io/tcp/8000' 
591+       ] 
592+       await  assertMatchUrl ( 
593+         `http://QmdmQXB2mzChmMeKY47C43LxUdg1NDJ5MWcKMKxDu7RgQm.ipfs.example.com?format=tar&provider=${ providers [ 0 ] }  &provider=${ providers [ 1 ] }  ` ,  { 
594+           protocol : 'ipfs' , 
595+           cid : 'QmdmQXB2mzChmMeKY47C43LxUdg1NDJ5MWcKMKxDu7RgQm' , 
596+           path : '' , 
597+           query : { 
598+             format : 'tar' , 
599+             provider : providers 
600+           } 
601+         } 
602+       ) 
603+     } ) 
604+ 
605+     it ( 'can parse an IPFS Subdomain Gateway URL with CID+path+queryString where query string has providers' ,  async  ( )  =>  { 
606+       const  providers  =  [ 
607+         '/dns4/provider-server.io/tcp/443/https' , 
608+         '/dns4/provider-server.io/tcp/8000' 
609+       ] 
610+       await  assertMatchUrl ( 
611+         `http://QmdmQXB2mzChmMeKY47C43LxUdg1NDJ5MWcKMKxDu7RgQm.ipfs.example.com/1 - Barrel - Part 1/1 - Barrel - Part 1 - alt.txt?format=tar&provider=${ providers [ 0 ] }  &provider=${ providers [ 1 ] }  ` ,  { 
612+           protocol : 'ipfs' , 
613+           cid : 'QmdmQXB2mzChmMeKY47C43LxUdg1NDJ5MWcKMKxDu7RgQm' , 
614+           path : '1 - Barrel - Part 1/1 - Barrel - Part 1 - alt.txt' , 
615+           query : { 
616+             format : 'tar' , 
617+             provider : providers 
618+           } 
619+         } 
620+       ) 
621+     } ) 
460622  } ) 
461623
462624  describe ( 'ipns://<peerId> URLs' ,  ( )  =>  { 
0 commit comments