Skip to content

Commit 1cd6689

Browse files
committed
adds support for filenames with parentheses
1 parent 686983f commit 1cd6689

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

lib/css-parser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
var embeddedRegexp = /^data:(.*?),(.*?)/;
22
var commentRegexp = /\/\*([\s\S]*?)\*\//g;
3-
var urlsRegexp = /((?:@import\s+)?url\s*\(\s*['"]?)(.*?)(['"]?\s*\))|(@import\s+['"]?)([^;'"]+)/ig;
3+
var urlsRegexp = /((?:@import\s+)?url\s*\(\s*['"]?)(.*?\..*?)(['"]?\s*\))|(@import\s+['"]?)([^;'"]+)/ig;
44

55
function isEmbedded (src) {
66
return embeddedRegexp.test(src.trim());

test/css-parser-test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,13 @@ describe('Parse css urls', function(){
8080
var urls = parseCssUrls(text);
8181
urls.should.be.instanceof(Array).and.have.lengthOf(1);
8282
urls.should.containEql(' a.css');
83+
});
84+
85+
it('should handle urls with parentheses inside quotes', function() {
86+
var text = '.image { background: url("a(1).css"); } ';
87+
var urls = parseCssUrls(text);
88+
urls.should.be.instanceof(Array).and.have.lengthOf(1);
89+
urls.should.containEql('a(1).css');
8390
});
8491

8592
describe('comments', function() {

0 commit comments

Comments
 (0)