diff --git a/src/utils/urlJoin.js b/src/utils/urlJoin.js index c3024f7e143..fe50ec26729 100644 --- a/src/utils/urlJoin.js +++ b/src/utils/urlJoin.js @@ -6,7 +6,7 @@ const path = require('path'); * e.g. from \path\to\res.js to /path/to/res.js. */ module.exports = function(publicURL, assetPath) { - const url = URL.parse(publicURL); + const url = URL.parse(publicURL, false, true); url.pathname = path.posix.join(url.pathname, URL.parse(assetPath).pathname); return URL.format(url); }; diff --git a/test/url-join.js b/test/url-join.js index 99dd7844f1f..aa64e9ae425 100644 --- a/test/url-join.js +++ b/test/url-join.js @@ -64,4 +64,11 @@ describe('Url Join', () => { it('should support windows paths', () => { assert.equal(urlJoin('dist\\foo', '\\bar\\foo.js'), 'dist/foo/bar/foo.js'); }); + + it('should parse double slashes as host', () => { + assert.equal( + urlJoin('//parceljs.org/foo?a=123&b=456#hello', 'bar/a.js'), + '//parceljs.org/foo/bar/a.js?a=123&b=456#hello' + ); + }); });