Skip to content

Commit 64f12dc

Browse files
evilebottnawimichael-ciniawsky
authored andcommittedFeb 15, 2018
fix(urls): skip empty url() handling (#304)
1 parent 91e0316 commit 64f12dc

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed
 

‎lib/urls.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ module.exports = function (css) {
6262
.replace(/^'(.*)'$/, function(o, $1){ return $1; });
6363

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

‎test/fixUrls.test.js

+11
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,17 @@ describe("fix urls tests", function() {
143143
assertUrl("body { background-image:url(#bg.jpg); }");
144144
});
145145

146+
// empty urls
147+
it("Empty url should be skipped", function() {
148+
assertUrl("body { background-image:url(); }");
149+
assertUrl("body { background-image:url( ); }");
150+
assertUrl("body { background-image:url(\n); }");
151+
assertUrl("body { background-image:url(''); }");
152+
assertUrl("body { background-image:url(' '); }");
153+
assertUrl("body { background-image:url(\"\"); }");
154+
assertUrl("body { background-image:url(\" \"); }");
155+
});
156+
146157
// rooted urls
147158
it("Rooted url", function() {
148159
assertUrl(

0 commit comments

Comments
 (0)
Please sign in to comment.