Skip to content

Commit 5461b91

Browse files
committed
1 parent b5edd42 commit 5461b91

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ module.exports = function(content, map) {
4444
var uriRegExp = /%CSSURL\[%(.*?)%\]CSSURL%/g;
4545
css = css.replace(uriRegExp, function(str) {
4646
var match = /^%CSSURL\[%(["']?(.*?)["']?)%\]CSSURL%$/.exec(JSON.parse('"' + str + '"'));
47-
var url = loaderUtils.parseString(match[2]);
48-
if(!loaderUtils.isUrlRequest(match[2], root)) return JSON.stringify(match[1]).replace(/^"|"$/g, "");
47+
var url = loaderUtils.parseString(match[1]);
48+
if(!loaderUtils.isUrlRequest(url, root)) return JSON.stringify(match[1]).replace(/^"|"$/g, "");
4949
var idx = url.indexOf("?#");
5050
if(idx < 0) idx = url.indexOf("#");
5151
if(idx > 0) {

test/urlTest.js

+4
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@ describe("url", function() {
115115
".class { background-image: url(\"data:image/svg+xml;charset=utf-8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 42 26' fill='%23007aff'><rect width='4' height='4'/><rect x='8' y='1' width='34' height='2'/><rect y='11' width='4' height='4'/><rect x='8' y='12' width='34' height='2'/><rect y='22' width='4' height='4'/><rect x='8' y='23' width='34' height='2'/></svg>\") }", [
116116
[1, ".class { background-image: url(\"data:image/svg+xml;charset=utf-8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 42 26' fill='%23007aff'><rect width='4' height='4'/><rect x='8' y='1' width='34' height='2'/><rect y='11' width='4' height='4'/><rect x='8' y='12' width='34' height='2'/><rect y='22' width='4' height='4'/><rect x='8' y='23' width='34' height='2'/></svg>\") }", ""]
117117
]);
118+
test("data url in filter",
119+
".class { filter: url('data:image/svg+xml;charset=utf-8,<svg xmlns=\"http://www.w3.org/2000/svg\"><filter id=\"filter\"><feGaussianBlur in=\"SourceAlpha\" stdDeviation=\"0\" /><feOffset dx=\"1\" dy=\"2\" result=\"offsetblur\" /><feFlood flood-color=\"rgba(255,255,255,1)\" /><feComposite in2=\"offsetblur\" operator=\"in\" /><feMerge><feMergeNode /><feMergeNode in=\"SourceGraphic\" /></feMerge></filter></svg>#filter'); }", [
120+
[1, ".class { filter: url('data:image/svg+xml;charset=utf-8,<svg xmlns=\"http://www.w3.org/2000/svg\"><filter id=\"filter\"><feGaussianBlur in=\"SourceAlpha\" stdDeviation=\"0\" /><feOffset dx=\"1\" dy=\"2\" result=\"offsetblur\" /><feFlood flood-color=\"rgba(255,255,255,1)\" /><feComposite in2=\"offsetblur\" operator=\"in\" /><feMerge><feMergeNode /><feMergeNode in=\"SourceGraphic\" /></feMerge></filter></svg>#filter'); }", ""]
121+
]);
118122
test("filter hash",
119123
".highlight { filter: url(#highlight); }", [
120124
[1, ".highlight { filter: url(#highlight); }", ""]

0 commit comments

Comments
 (0)