main
Last change
on this file since 79a0317 was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 4 days ago |
F4 Finalna Verzija
|
-
Property mode
set to
100644
|
File size:
1.0 KB
|
Line | |
---|
1 | var OptimizationLevel = require('../../../options/optimization-level').OptimizationLevel;
|
---|
2 |
|
---|
3 | var LOCAL_PREFIX_PATTERN = /^local\(/i;
|
---|
4 | var QUOTED_PATTERN = /^('.*'|".*")$/;
|
---|
5 | var QUOTED_BUT_SAFE_PATTERN = /^['"][a-zA-Z][a-zA-Z\d\-_]+['"]$/;
|
---|
6 | // eslint-disable-next-line max-len
|
---|
7 | var GENERIC_FONT_FAMILY_PATTERN = /^['"](?:cursive|default|emoji|fangsong|fantasy|inherit|initial|math|monospace|revert|revert-layer|sans-serif|serif|system-ui|ui-monospace|ui-rounded|ui-sans-serif|ui-serif|unset)['"]$/;
|
---|
8 |
|
---|
9 | var plugin = {
|
---|
10 | level1: {
|
---|
11 | value: function textQuotes(name, value, options) {
|
---|
12 | if ((name == 'font-family' || name == 'font') && GENERIC_FONT_FAMILY_PATTERN.test(value)) {
|
---|
13 | return value;
|
---|
14 | }
|
---|
15 |
|
---|
16 | if (!options.level[OptimizationLevel.One].removeQuotes) {
|
---|
17 | return value;
|
---|
18 | }
|
---|
19 |
|
---|
20 | if (!QUOTED_PATTERN.test(value) && !LOCAL_PREFIX_PATTERN.test(value)) {
|
---|
21 | return value;
|
---|
22 | }
|
---|
23 |
|
---|
24 | return QUOTED_BUT_SAFE_PATTERN.test(value)
|
---|
25 | ? value.substring(1, value.length - 1)
|
---|
26 | : value;
|
---|
27 | }
|
---|
28 | }
|
---|
29 | };
|
---|
30 |
|
---|
31 | module.exports = plugin;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.