File tree 3 files changed +61
-1
lines changed 3 files changed +61
-1
lines changed Original file line number Diff line number Diff line change 669
669
670
670
URI . build = function ( parts ) {
671
671
var t = '' ;
672
+ var requireAbsolutePath = false
672
673
673
674
if ( parts . protocol ) {
674
675
t += parts . protocol + ':' ;
675
676
}
676
677
677
678
if ( ! parts . urn && ( t || parts . hostname ) ) {
678
679
t += '//' ;
680
+ requireAbsolutePath = true
679
681
}
680
682
681
683
t += ( URI . buildAuthority ( parts ) || '' ) ;
682
684
683
685
if ( typeof parts . path === 'string' ) {
684
- if ( parts . path . charAt ( 0 ) !== '/' && typeof parts . hostname === 'string' ) {
686
+ if ( parts . path . charAt ( 0 ) !== '/' && requireAbsolutePath ) {
685
687
t += '/' ;
686
688
}
687
689
Original file line number Diff line number Diff line change 234
234
} ) ( t ) ;
235
235
}
236
236
237
+ module ( 'serializing' ) ;
238
+ test ( 'scheme and relative path' , function ( ) {
239
+ var u = new URI ( '' )
240
+ . protocol ( 'food' )
241
+ . path ( 'test/file.csv' )
242
+ . toString ( )
243
+
244
+ equal ( u . toString ( ) , 'food:///test/file.csv' , 'relative-path with scheme but no authority' ) ;
245
+ } ) ;
246
+
237
247
module ( 'mutating basics' ) ;
238
248
test ( 'protocol' , function ( ) {
239
249
var u = new URI ( 'http://example.org/foo.html' ) ;
Original file line number Diff line number Diff line change @@ -629,6 +629,54 @@ var urls = [{
629
629
idn : false ,
630
630
punycode : false
631
631
}
632
+ } , {
633
+ name : 'missing authority' ,
634
+ url : 'food:///test/file.csv' ,
635
+ parts : {
636
+ protocol : 'food' ,
637
+ username : null ,
638
+ password : null ,
639
+ hostname : null ,
640
+ port : null ,
641
+ path : '/test/file.csv' ,
642
+ query : null ,
643
+ fragment : null
644
+ } ,
645
+ accessors : {
646
+ protocol : 'food' ,
647
+ username : '' ,
648
+ password : '' ,
649
+ port : '' ,
650
+ path : '/test/file.csv' ,
651
+ query : '' ,
652
+ fragment : '' ,
653
+ resource : '/test/file.csv' ,
654
+ authority : '' ,
655
+ origin : '' ,
656
+ userinfo : '' ,
657
+ subdomain : '' ,
658
+ domain : '' ,
659
+ tld : '' ,
660
+ directory : '/test' ,
661
+ filename : 'file.csv' ,
662
+ suffix : 'csv' ,
663
+ hash : '' ,
664
+ search : '' ,
665
+ host : '' ,
666
+ hostname : ''
667
+ } ,
668
+ is : {
669
+ urn : false ,
670
+ url : true ,
671
+ relative : true ,
672
+ name : false ,
673
+ sld : false ,
674
+ ip : false ,
675
+ ip4 : false ,
676
+ ip6 : false ,
677
+ idn : false ,
678
+ punycode : false
679
+ }
632
680
} , {
633
681
name : 'IPv4' ,
634
682
url : 'http://user:pass@123.123.123.123:123/some/directory/file.html?query=string#fragment' ,
You can’t perform that action at this time.
0 commit comments