Fixes #110 - do not strip parentheses for data URIs in url() declaration.
authorGoalSmashers <jakub@goalsmashers.com>
Tue, 4 Jun 2013 18:21:07 +0000 (20:21 +0200)
committerGoalSmashers <jakub@goalsmashers.com>
Tue, 4 Jun 2013 18:21:07 +0000 (20:21 +0200)
lib/clean.js
test/unit-test.js

index 859cf11..68e49ce 100644 (file)
@@ -92,7 +92,7 @@ var CleanCSS = {
 
     // strip parentheses in urls if possible (no spaces inside)
     replace(/url\((['"])([^\)]+)['"]\)/g, function(match, quote, url) {
-      if (url.match(/[ \t]/g) !== null)
+      if (url.match(/[ \t]/g) !== null || url.indexOf('data:') === 0)
         return 'url(' + quote + url + quote + ')';
       else
         return 'url(' + url + ')';
index 7f55860..bf29f0e 100644 (file)
@@ -559,6 +559,7 @@ vows.describe('clean-units').addBatch({
   }),
   'urls': cssContext({
     'keep urls without parentheses unchanged': 'a{background:url(/images/blank.png) 0 0 no-repeat}',
+    'keep urls with data URI unchanged': ".icon-logo{background-image:url('data:image/svg+xml;charset=US-ASCII')}",
     'strip single parentheses': [
       "a{background:url('/images/blank.png') 0 0 no-repeat}",
       "a{background:url(/images/blank.png) 0 0 no-repeat}"