Skip to content

Commit a78280a

Browse files
iifeoluwadevongovett
authored andcommitted
Fixes bug where double slashes isn't parsed as host. (#599)
* Added test for parsing double slashes as host * Parse double slashes as host
1 parent 0a2f554 commit a78280a

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

ā€Žsrc/utils/urlJoin.jsā€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const path = require('path');
66
* e.g. from \path\to\res.js to /path/to/res.js.
77
*/
88
module.exports = function(publicURL, assetPath) {
9-
const url = URL.parse(publicURL);
9+
const url = URL.parse(publicURL, false, true);
1010
url.pathname = path.posix.join(url.pathname, URL.parse(assetPath).pathname);
1111
return URL.format(url);
1212
};

ā€Žtest/url-join.jsā€Ž

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,11 @@ describe('Url Join', () => {
6464
it('should support windows paths', () => {
6565
assert.equal(urlJoin('dist\\foo', '\\bar\\foo.js'), 'dist/foo/bar/foo.js');
6666
});
67+
68+
it('should parse double slashes as host', () => {
69+
assert.equal(
70+
urlJoin('//parceljs.org/foo?a=123&b=456#hello', 'bar/a.js'),
71+
'//parceljs.org/foo/bar/a.js?a=123&b=456#hello'
72+
);
73+
});
6774
});

0 commit comments

Comments
Ā (0)
⚔