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 9713ed6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/urls.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ module.exports = function (css) {
.replace(/^'(.*)'$/, function(o, $1){ return $1; });

// already a full url? no change
if (/^(#|data:|http:\/\/|https:\/\/|file:\/\/\/)/i.test(unquotedOrigUrl)) {
return fullMatch;
if (/^(#|data:|http:\/\/|https:\/\/|file:\/\/\/|\s*$)/i.test(unquotedOrigUrl)) {
return fullMatch;
}

// convert the url to a full url
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 9713ed6

Please sign in to comment.