diff --git a/lib/processCss.js b/lib/processCss.js index 181f7a2ab..4e78ca9b1 100644 --- a/lib/processCss.js +++ b/lib/processCss.js @@ -153,6 +153,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 b54bf9a8b..74283f0ca 100644 --- a/test/urlTest.js +++ b/test/urlTest.js @@ -12,6 +12,9 @@ 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 4", ".class { background: green url( img.png ) xyz }", [ + [1, ".class { background: green url({./img.png}) xyz }", ""] + ]); test("background img absolute", ".class { background: green url(/img.png) xyz }", [ [1, ".class { background: green url(/img.png) xyz }", ""] ]); @@ -63,6 +66,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 absolute with url", ".class { background: green url(/img.png) xyz }", [ [1, ".class { background: green url(/img.png) xyz }", ""] ], "?-url");