Skip to content

Commit

Permalink
Fixes bug where double slashes isn't parsed as host. (#599)
Browse files Browse the repository at this point in the history
* Added test for parsing double slashes as host

* Parse double slashes as host
  • Loading branch information
iifeoluwa authored and devongovett committed Jan 21, 2018
1 parent 0a2f554 commit a78280a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/utils/urlJoin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
7 changes: 7 additions & 0 deletions test/url-join.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
);
});
});

0 comments on commit a78280a

Please sign in to comment.