web-deploy/node_modules/clean-css/lib/optimizer/level-1/value-optimizers/url-quotes.js
2024-04-26 18:37:00 +01:00

23 lines
622 B
JavaScript

var QUOTED_URL_PATTERN = /^url\(['"].+['"]\)$/;
var QUOTED_URL_WITH_WHITESPACE_PATTERN = /^url\(['"].*[*\s()'"].*['"]\)$/;
var QUOTES_PATTERN = /["']/g;
var URL_DATA_PATTERN = /^url\(['"]data:[^;]+;charset/;
var plugin = {
level1: {
value: function urlQuotes(_name, value, options) {
if (options.compatibility.properties.urlQuotes) {
return value;
}
return QUOTED_URL_PATTERN.test(value)
&& !QUOTED_URL_WITH_WHITESPACE_PATTERN.test(value)
&& !URL_DATA_PATTERN.test(value)
? value.replace(QUOTES_PATTERN, '')
: value;
}
}
};
module.exports = plugin;