Skip to content

Commit 13aaf0f

Browse files
razhSpaceK33z
authored andcommitted
Fix protocol-relative urls with publicPath (#129)
Pass `true` for `slashesDenoteHost` in `url.parse`. https://nodejs.org/api/url.html#url_url_parse_urlstring_parsequerystring_slashesdenotehost Fixes #128
1 parent 652f50a commit 13aaf0f

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

lib/GetFilenameFromUrl.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ function getFilenameFromUrl(publicPath, outputPath, url) {
55
var filename;
66

77
// localPrefix is the folder our bundle should be in
8-
var localPrefix = urlParse(publicPath || "/");
8+
var localPrefix = urlParse(publicPath || "/", false, true);
99
var urlObject = urlParse(url);
1010

1111
// publicPath has the hostname that is not the same as request url's, should fail

test/GetFilenameFromUrl.test.js

+5
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ describe("GetFilenameFromUrl", function() {
7979
outputPath: "/",
8080
publicPath: "http://other.domain/test/",
8181
expected: false
82+
}, {
83+
url: "/protocol/relative/sample.js",
84+
outputPath: "/",
85+
publicPath: "//test.domain/protocol/relative/",
86+
expected: "/sample.js"
8287
}
8388
];
8489
results.forEach(testUrl);

0 commit comments

Comments
 (0)