Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(urls): skip empty url() handling #304

Merged
merged 1 commit into from
Feb 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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