You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
622 B
23 lines
622 B
2 years ago
|
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;
|