Skip to content

Commit e1ec4f2

Browse files
evilebottnawimichael-ciniawsky
authored andcommitted
fix: url with a trailing space is now handled correctly (#494)
1 parent fbb0714 commit e1ec4f2

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

lib/processCss.js

+2
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ module.exports = function processCss(inputSource, inputMap, options, callback) {
156156
mode: options.mode,
157157
rewriteUrl: function(global, url) {
158158
if(parserOptions.url){
159+
url = url.trim(" ");
160+
159161
if(!loaderUtils.isUrlRequest(url, root)) {
160162
return url;
161163
}

test/urlTest.js

+11-5
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,15 @@ describe("url", function() {
1212
test("background img 3", ".class { background: green url( 'img.png' ) xyz }", [
1313
[1, ".class { background: green url({./img.png}) xyz }", ""]
1414
]);
15-
test("background img contain space in name", ".class { background: green url( \"img img.png\" ) xyz }", [
16-
[1, ".class { background: green url(\"{./img img.png}\") xyz }", ""]
17-
]);
18-
test("background 2 img contain space in name", ".class { background: green url( 'img img.png' ) xyz }", [
19-
[1, ".class { background: green url('{./img img.png}') xyz }", ""]
15+
test("background img 4", ".class { background: green url( img.png ) xyz }", [
16+
[1, ".class { background: green url({./img.png}) xyz }", ""]
2017
]);
18+
test("background img contain space in name", ".class { background: green url( \"img img.png\" ) xyz }", [
19+
[1, ".class { background: green url(\"{./img img.png}\") xyz }", ""]
20+
]);
21+
test("background 2 img contain space in name", ".class { background: green url( 'img img.png' ) xyz }", [
22+
[1, ".class { background: green url('{./img img.png}') xyz }", ""]
23+
]);
2124
test("background img absolute", ".class { background: green url(/img.png) xyz }", [
2225
[1, ".class { background: green url(/img.png) xyz }", ""]
2326
]);
@@ -77,6 +80,9 @@ describe("url", function() {
7780
test("background img 3 with url", ".class { background: green url( 'img.png' ) xyz }", [
7881
[1, ".class { background: green url( 'img.png' ) xyz }", ""]
7982
], "?-url");
83+
test("background img 4 with url", ".class { background: green url( img.png ) xyz }", [
84+
[1, ".class { background: green url( img.png ) xyz }", ""]
85+
], "?-url");
8086
test("background img with url contain space in name", ".class { background: green url( \"img img.png\" ) xyz }", [
8187
[1, ".class { background: green url( \"img img.png\" ) xyz }", ""]
8288
], "?-url");

0 commit comments

Comments
 (0)