File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -45,4 +45,29 @@ describe('joinUrls', () => {
4545 'https://cdn.example.com/base/file.txt' ,
4646 ] ) ;
4747 } ) ;
48+
49+ test ( 'handles empty string paths' , ( ) => {
50+ expect ( joinUrls ( [ '' ] , 'file.txt' ) ) . toEqual ( [ 'https:///file.txt' ] ) ;
51+ } ) ;
52+
53+ test ( 'trims multiple trailing slashes' , ( ) => {
54+ expect ( joinUrls ( [ 'example.com///' , 'http://example.com///' ] , 'file.txt' ) ) . toEqual ( [
55+ 'https://example.com/file.txt' ,
56+ 'http://example.com/file.txt' ,
57+ ] ) ;
58+ } ) ;
59+
60+ test ( 'preserves custom protocols' , ( ) => {
61+ expect ( joinUrls ( [ 'ftp://example.com' , 'myapp://some/path' ] , 'file.txt' ) ) . toEqual ( [
62+ 'ftp://example.com/file.txt' ,
63+ 'myapp://some/path/file.txt' ,
64+ ] ) ;
65+ } ) ;
66+
67+ test ( 'prepends https:// to IP addresses with ports' , ( ) => {
68+ expect ( joinUrls ( [ '192.168.1.1:8080' , '10.0.0.1:3000/api' ] , 'file.txt' ) ) . toEqual ( [
69+ 'https://192.168.1.1:8080/file.txt' ,
70+ 'https://10.0.0.1:3000/api/file.txt' ,
71+ ] ) ;
72+ } ) ;
4873} ) ;
You can’t perform that action at this time.
0 commit comments