Skip to content

Commit 4bca612

Browse files
committed
PR feedback: support http/https only
1 parent 9124835 commit 4bca612

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

lib/urlToRequest.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ function urlToRequest(url, root) {
3030
default:
3131
throw new Error("Unexpected parameters to loader-utils 'urlToRequest': url = " + url + ", root = " + root + ".");
3232
}
33-
} else if(/^[a-z][a-z0-9+\-.]*:\/\//.test(url)) {
34-
// An absolute url stays
33+
} else if(/^https?:\/\//.test(url)) {
34+
// Preserve http and https urls
3535
request = url;
3636
} else if(/^\.\.?\//.test(url)) {
3737
// A relative url stays

test/urlToRequest.test.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ ExpectedError.prototype.matches = function(err) {
1313
describe("urlToRequest()", () => {
1414
[
1515
// without root
16-
[["https://google.com"], "https://google.com", "should handle absolute urls"],
16+
[["http://google.com"], "http://google.com", "should handle http urls"],
17+
[["https://google.com"], "https://google.com", "should handle https urls"],
1718
[["path/to/thing"], "./path/to/thing", "should handle implicit relative urls"],
1819
[["./path/to/thing"], "./path/to/thing", "should handle explicit relative urls"],
1920
[["~path/to/thing"], "path/to/thing", "should handle module urls (with ~)"],

0 commit comments

Comments
 (0)