From 1cd6689fee9cb269e4c8928f1613077dd0cfb992 Mon Sep 17 00:00:00 2001 From: Carl Henderson Date: Sun, 7 Jan 2018 10:42:32 -0500 Subject: [PATCH] adds support for filenames with parentheses --- lib/css-parser.js | 2 +- test/css-parser-test.js | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/css-parser.js b/lib/css-parser.js index 78407af..fa12b43 100644 --- a/lib/css-parser.js +++ b/lib/css-parser.js @@ -1,6 +1,6 @@ var embeddedRegexp = /^data:(.*?),(.*?)/; var commentRegexp = /\/\*([\s\S]*?)\*\//g; -var urlsRegexp = /((?:@import\s+)?url\s*\(\s*['"]?)(.*?)(['"]?\s*\))|(@import\s+['"]?)([^;'"]+)/ig; +var urlsRegexp = /((?:@import\s+)?url\s*\(\s*['"]?)(.*?\..*?)(['"]?\s*\))|(@import\s+['"]?)([^;'"]+)/ig; function isEmbedded (src) { return embeddedRegexp.test(src.trim()); diff --git a/test/css-parser-test.js b/test/css-parser-test.js index 1e8d966..9302112 100644 --- a/test/css-parser-test.js +++ b/test/css-parser-test.js @@ -80,6 +80,13 @@ describe('Parse css urls', function(){ var urls = parseCssUrls(text); urls.should.be.instanceof(Array).and.have.lengthOf(1); urls.should.containEql(' a.css'); + }); + + it('should handle urls with parentheses inside quotes', function() { + var text = '.image { background: url("a(1).css"); } '; + var urls = parseCssUrls(text); + urls.should.be.instanceof(Array).and.have.lengthOf(1); + urls.should.containEql('a(1).css'); }); describe('comments', function() {