From 639bef177332bb6076edfb0ec90709ed00daae80 Mon Sep 17 00:00:00 2001 From: evilebottnawi Date: Wed, 26 Apr 2017 13:34:58 +0300 Subject: [PATCH] Fixed: trim url first. --- lib/processCss.js | 10 +++++----- test/urlTest.js | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/processCss.js b/lib/processCss.js index 9ce76c3a..81924375 100644 --- a/lib/processCss.js +++ b/lib/processCss.js @@ -161,18 +161,18 @@ module.exports = function processCss(inputSource, inputMap, options, callback) { var pipeline = postcss([ localByDefault({ mode: options.mode, - rewriteUrl: function(global, origUrl) { + rewriteUrl: function(global, url) { if(parserOptions.url){ - var url = origUrl.trim(" "); + url = url.trim(); - if(!origUrl.replace(/\s/g, '').length || !loaderUtils.isUrlRequest(url, root)) { - return origUrl; + if(!url.replace(/\s/g, '').length || !loaderUtils.isUrlRequest(url, root)) { + return url; } if(global) { return loaderUtils.urlToRequest(url, root); } } - return origUrl; + return url; } }), extractImports(), diff --git a/test/urlTest.js b/test/urlTest.js index aa690271..b5221e9b 100644 --- a/test/urlTest.js +++ b/test/urlTest.js @@ -77,16 +77,16 @@ describe("url", function() { [1, ".class { background: green url('') xyz }", ""] ]); test("empty url with spaces and quotes", ".class { background: green url(' ') xyz }", [ - [1, ".class { background: green url(' ') xyz }", ""] + [1, ".class { background: green url('') xyz }", ""] ]); test("empty url with newline and quotes", ".class { background: green url('\n') xyz }", [ - [1, ".class { background: green url('\n') xyz }", ""] + [1, ".class { background: green url('') xyz }", ""] ]); test("empty url with CRLF and quotes", ".class { background: green url('\r\n') xyz }", [ - [1, ".class { background: green url('\r\n') xyz }", ""] + [1, ".class { background: green url('') xyz }", ""] ]); test("empty url with tab and quotes", ".class { background: green url('\t') xyz }", [ - [1, ".class { background: green url('\t') xyz }", ""] + [1, ".class { background: green url('') xyz }", ""] ]); test("external absolute url", ".class { background: green url(https://raw.githubusercontent.com/webpack/media/master/logo/icon.png) xyz }", [ [1, ".class { background: green url(https://raw.githubusercontent.com/webpack/media/master/logo/icon.png) xyz }", ""]