From: GoalSmashers Date: Tue, 4 Jun 2013 18:21:07 +0000 (+0200) Subject: Fixes #110 - do not strip parentheses for data URIs in url() declaration. X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=6a49669d0fca130554ec1e1d2133b030c07c8371;p=clean-css.git Fixes #110 - do not strip parentheses for data URIs in url() declaration. --- diff --git a/lib/clean.js b/lib/clean.js index 859cf114..68e49cee 100644 --- a/lib/clean.js +++ b/lib/clean.js @@ -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 + ')'; diff --git a/test/unit-test.js b/test/unit-test.js index 7f55860b..bf29f0ec 100644 --- a/test/unit-test.js +++ b/test/unit-test.js @@ -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}"