Skip to content

Commit 5986fba

Browse files
committed
Merge branch 'martnu-fix-non-url-requests-in-module-mode'
2 parents 4a55bb8 + 11b438e commit 5986fba

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

lib/loader.js

+2-5
Original file line numberDiff line numberDiff line change
@@ -114,19 +114,16 @@ module.exports = function(content, map) {
114114
if(!stuff.urls[idx]) return str;
115115
var urlItem = stuff.urls[idx];
116116
var url = urlItem.url;
117-
if(!moduleMode && !loaderUtils.isUrlRequest(url, root))
117+
if(!loaderUtils.isUrlRequest(url, root))
118118
return toEmbStr(urlItem.raw);
119119
idx = url.indexOf("?#");
120120
if(idx < 0) idx = url.indexOf("#");
121121
var urlRequest;
122-
if(idx > 0) {
122+
if(idx > 0) { // idx === 0 is catched by isUrlRequest
123123
// in cases like url('webfont.eot?#iefix')
124124
urlRequest = url.substr(0, idx);
125125
if(!moduleMode) urlRequest = loaderUtils.urlToRequest(urlRequest, root);
126126
return "\"+require(" + loaderUtils.stringifyRequest(this, urlRequest) + ")+\"" + url.substr(idx);
127-
} else if(idx === 0) {
128-
// only hash
129-
return toEmbStr(urlItem.raw);
130127
}
131128
urlRequest = url;
132129
if(!moduleMode) urlRequest = loaderUtils.urlToRequest(url, root);

test/moduleTestCases/urls/expected.css

+4
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,8 @@
55
background: url({./module}#?iefix);
66
background: url("#hash");
77
background: url("#");
8+
background: url(data:image/png;base64,AAA);
9+
background: url(http://example.com/image.jpg);
10+
background: url(//example.com/image.png);
11+
background: green url(data:image/png;base64,AAA) url(http://example.com/image.jpg) url(//example.com/image.png) url({./module}) xyz;
812
}

test/moduleTestCases/urls/source.css

+4
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,8 @@
55
background: url("./module#?iefix");
66
background: url("#hash");
77
background: url("#");
8+
background: url(data:image/png;base64,AAA);
9+
background: url(http://example.com/image.jpg);
10+
background: url(//example.com/image.png);
11+
background: green url(data:image/png;base64,AAA) url(http://example.com/image.jpg) url(//example.com/image.png) url(./module) xyz;
812
}

0 commit comments

Comments
 (0)