From 6a49669d0fca130554ec1e1d2133b030c07c8371 Mon Sep 17 00:00:00 2001 From: GoalSmashers Date: Tue, 4 Jun 2013 20:21:07 +0200 Subject: [PATCH] Fixes #110 - do not strip parentheses for data URIs in url() declaration. --- lib/clean.js | 2 +- test/unit-test.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) 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}" -- 2.34.1