Skip to content

Commit f432044

Browse files
🧪 test: add edge case tests for joinUrls (#539)
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> Co-authored-by: sunnylqm <615282+sunnylqm@users.noreply.github.com>
1 parent 800cd10 commit f432044

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

‎src/__tests__/utils.test.ts‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff 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
});

0 commit comments

Comments
 (0)