diff --git a/lib/processCss.js b/lib/processCss.js index 181f7a2ab..b1a5751f7 100644 --- a/lib/processCss.js +++ b/lib/processCss.js @@ -153,11 +153,13 @@ module.exports = function processCss(inputSource, inputMap, options, callback) { mode: options.mode, rewriteUrl: function(global, url) { if(parserOptions.url){ - if(!loaderUtils.isUrlRequest(url, root)) { + var unspacedUrlString = url.trim(" "); + + if(!loaderUtils.isUrlRequest(unspacedUrlString, root)) { return url; } if(global) { - return loaderUtils.urlToRequest(url, root); + return loaderUtils.urlToRequest(unspacedUrlString, 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");