diff --git a/lib/urls.js b/lib/urls.js index d215ae84..a2259aba 100644 --- a/lib/urls.js +++ b/lib/urls.js @@ -62,7 +62,7 @@ module.exports = function (css) { .replace(/^'(.*)'$/, function(o, $1){ return $1; }); // already a full url? no change - if (/^(#|data:|http:\/\/|https:\/\/|file:\/\/\/)/i.test(unquotedOrigUrl)) { + if (/^(#|data:|http:\/\/|https:\/\/|file:\/\/\/|\s*$)/i.test(unquotedOrigUrl)) { return fullMatch; } diff --git a/test/fixUrls.test.js b/test/fixUrls.test.js index d8d6ae57..3781eedf 100644 --- a/test/fixUrls.test.js +++ b/test/fixUrls.test.js @@ -143,6 +143,17 @@ describe("fix urls tests", function() { assertUrl("body { background-image:url(#bg.jpg); }"); }); + // empty urls + it("Empty url should be skipped", function() { + assertUrl("body { background-image:url(); }"); + assertUrl("body { background-image:url( ); }"); + assertUrl("body { background-image:url(\n); }"); + assertUrl("body { background-image:url(''); }"); + assertUrl("body { background-image:url(' '); }"); + assertUrl("body { background-image:url(\"\"); }"); + assertUrl("body { background-image:url(\" \"); }"); + }); + // rooted urls it("Rooted url", function() { assertUrl(