diff --git a/lib/processCss.js b/lib/processCss.js index 7f42736f..7a7edb1d 100644 --- a/lib/processCss.js +++ b/lib/processCss.js @@ -156,6 +156,8 @@ module.exports = function processCss(inputSource, inputMap, options, callback) { mode: options.mode, rewriteUrl: function(global, url) { if(parserOptions.url){ + url = url.trim(" "); + if(!loaderUtils.isUrlRequest(url, root)) { return url; } diff --git a/test/urlTest.js b/test/urlTest.js index 9eec659b..e25a4b77 100644 --- a/test/urlTest.js +++ b/test/urlTest.js @@ -12,12 +12,15 @@ describe("url", function() { test("background img 3", ".class { background: green url( 'img.png' ) xyz }", [ [1, ".class { background: green url({./img.png}) xyz }", ""] ]); - test("background img contain space in name", ".class { background: green url( \"img img.png\" ) xyz }", [ - [1, ".class { background: green url(\"{./img img.png}\") xyz }", ""] - ]); - test("background 2 img contain space in name", ".class { background: green url( 'img img.png' ) xyz }", [ - [1, ".class { background: green url('{./img img.png}') xyz }", ""] + test("background img 4", ".class { background: green url( img.png ) xyz }", [ + [1, ".class { background: green url({./img.png}) xyz }", ""] ]); + test("background img contain space in name", ".class { background: green url( \"img img.png\" ) xyz }", [ + [1, ".class { background: green url(\"{./img img.png}\") xyz }", ""] + ]); + test("background 2 img contain space in name", ".class { background: green url( 'img img.png' ) xyz }", [ + [1, ".class { background: green url('{./img img.png}') xyz }", ""] + ]); test("background img absolute", ".class { background: green url(/img.png) xyz }", [ [1, ".class { background: green url(/img.png) xyz }", ""] ]); @@ -77,6 +80,9 @@ describe("url", function() { test("background img 3 with url", ".class { background: green url( 'img.png' ) xyz }", [ [1, ".class { background: green url( 'img.png' ) xyz }", ""] ], "?-url"); + test("background img 4 with url", ".class { background: green url( img.png ) xyz }", [ + [1, ".class { background: green url( img.png ) xyz }", ""] + ], "?-url"); test("background img with url contain space in name", ".class { background: green url( \"img img.png\" ) xyz }", [ [1, ".class { background: green url( \"img img.png\" ) xyz }", ""] ], "?-url");