Skip to content

Commit 29ecf47

Browse files
committed
parse urls in strings correctly #54
1 parent a66165d commit 29ecf47

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

lib/parseSource.js

+4
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ var parser = new Parser({
3535
source: {
3636
"/\\*": "comment",
3737

38+
// strings
39+
'"([^\\\\"]|\\\\.)*"': true,
40+
"'([^\\\\']|\\\\.)*'": true,
41+
3842
// imports
3943
'@\\s*import\\s+"([^"]*)"\\s*([^;\\n]*);': importMatch,
4044
"@\\s*import\\s+'([^'']*)'\\s*([^;\\n]*);": importMatch,

test/urlTest.js

+3
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,9 @@ describe("url", function() {
143143
test("media query", "@media (min-width: 500px) { body { background: url(image.png); } }", [
144144
[1, "@media (min-width: 500px) { body { background: url({./image.png}); } }", ""]
145145
]);
146+
test("url in string", "a { content: \"do not use url(path)\"; } b { content: 'do not \"use\" url(path)'; }", [
147+
[1, "a { content: \"do not use url(path)\"; } b { content: 'do not \"use\" url(path)'; }", ""]
148+
]);
146149
test("locals", ".local[className] { background: red; }\n#local[someId] { background: green; }\n" +
147150
".local[className] .local[subClass] { color: green; }\n#local[someId] .local[subClass] { color: blue; }", function() { var r = [
148151
[1, "._23_aKvs-b8bW2Vg3fwHozO { background: red; }\n#_1j3LM6lKkKzRIt19ImYVnD { background: green; }\n" +

0 commit comments

Comments
 (0)