Skip to content

Commit 639bef1

Browse files
author
evilebottnawi
committed
Fixed: trim url first.
1 parent a62bb30 commit 639bef1

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

lib/processCss.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -161,18 +161,18 @@ module.exports = function processCss(inputSource, inputMap, options, callback) {
161161
var pipeline = postcss([
162162
localByDefault({
163163
mode: options.mode,
164-
rewriteUrl: function(global, origUrl) {
164+
rewriteUrl: function(global, url) {
165165
if(parserOptions.url){
166-
var url = origUrl.trim(" ");
166+
url = url.trim();
167167

168-
if(!origUrl.replace(/\s/g, '').length || !loaderUtils.isUrlRequest(url, root)) {
169-
return origUrl;
168+
if(!url.replace(/\s/g, '').length || !loaderUtils.isUrlRequest(url, root)) {
169+
return url;
170170
}
171171
if(global) {
172172
return loaderUtils.urlToRequest(url, root);
173173
}
174174
}
175-
return origUrl;
175+
return url;
176176
}
177177
}),
178178
extractImports(),

test/urlTest.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,16 @@ describe("url", function() {
7777
[1, ".class { background: green url('') xyz }", ""]
7878
]);
7979
test("empty url with spaces and quotes", ".class { background: green url(' ') xyz }", [
80-
[1, ".class { background: green url(' ') xyz }", ""]
80+
[1, ".class { background: green url('') xyz }", ""]
8181
]);
8282
test("empty url with newline and quotes", ".class { background: green url('\n') xyz }", [
83-
[1, ".class { background: green url('\n') xyz }", ""]
83+
[1, ".class { background: green url('') xyz }", ""]
8484
]);
8585
test("empty url with CRLF and quotes", ".class { background: green url('\r\n') xyz }", [
86-
[1, ".class { background: green url('\r\n') xyz }", ""]
86+
[1, ".class { background: green url('') xyz }", ""]
8787
]);
8888
test("empty url with tab and quotes", ".class { background: green url('\t') xyz }", [
89-
[1, ".class { background: green url('\t') xyz }", ""]
89+
[1, ".class { background: green url('') xyz }", ""]
9090
]);
9191
test("external absolute url", ".class { background: green url(https://raw.githubusercontent.com/webpack/media/master/logo/icon.png) xyz }", [
9292
[1, ".class { background: green url(https://raw.githubusercontent.com/webpack/media/master/logo/icon.png) xyz }", ""]

0 commit comments

Comments
 (0)