Skip to content

Commit

Permalink
fix: skip handle empty url
Browse files Browse the repository at this point in the history
  • Loading branch information
evilebottnawi committed Feb 15, 2018
1 parent 91e0316 commit 0b21fce
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/urls.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
11 changes: 11 additions & 0 deletions test/fixUrls.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 0b21fce

Please sign in to comment.