}
function rewriteUrls(data, options, context) {
- return reduceUrls(data, context, function (url, tempData) {
- url = url.replace(/^(url\()?\s*['"]?|['"]?\s*\)?$/g, '');
- tempData.push('url(' + quoteFor(url) + rebase(url, options) + quoteFor(url) + ')');
+ return reduceUrls(data, context, function (originUrl, tempData) {
+ var url = originUrl.replace(/^(url\()?\s*['"]?|['"]?\s*\)?$/g, '');
+ var match = originUrl.match(/^(url\()?\s*(['"]).*?(['"])\s*\)?$/);
+ var quote;
+ if (!!options.urlQuotes && match && match[2] === match[3]) {
+ quote = match[2];
+ } else {
+ quote = quoteFor(url);
+ }
+ tempData.push('url(' + quote + rebase(url, options) + quote + ')');
});
}
imports: true,
rebase: self.outerContext.options.rebase,
fromBase: absoluteSourcePath,
- toBase: isRemote ? absoluteSourcePath : toBase
+ toBase: isRemote ? absoluteSourcePath : toBase,
+ urlQuotes: self.outerContext.options.compatibility.properties.urlQuotes
};
styles = rewriteUrls(styles, rewriteOptions, self.outerContext);
'keeps quotes as they are': [
'div{background:url("test.png")}',
'div{background:url("test.png")}'
+ ],
+ 'keeps quotes as they are when minify hash data': [
+ {'temp/file.css': {
+ styles: 'div{background:url("test.png")}'
+ }},
+ 'div{background:url("temp/test.png")}'
+ ],
+ 'no quotes added when minify hash data': [
+ {'temp/file.css': {
+ styles: 'div{background:url(test.png)}'
+ }},
+ 'div{background:url(temp/test.png)}'
]
}, { compatibility: { properties: { urlQuotes: true } } })
)