Skip to content

Commit

Permalink
refactor: improve
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-akait committed Apr 14, 2023
1 parent f1cf224 commit d1634b8
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/css/CssParser.js
Expand Up @@ -23,9 +23,13 @@ const CC_COLON = ":".charCodeAt(0);
const CC_SLASH = "/".charCodeAt(0);
const CC_SEMICOLON = ";".charCodeAt(0);

const STRING_MULTILINE = /\\(\n|\r\n|\r|\f)/g;
const TRIM_WHITE_SPACES = /(^( |\t\n|\r\n|\r|\f)*|( |\t\n|\r\n|\r|\f)*$)/g;
// https://www.w3.org/TR/css-syntax-3/#newline
// We don't have `preprocessing` stage, so we need specify all of them
const STRING_MULTILINE = /\\[\n\r\f]/g;
// https://www.w3.org/TR/css-syntax-3/#whitespace
const TRIM_WHITE_SPACES = /(^[ \t\n\r\f]*|[ \t\n\r\f]*$)/g;
const UNESCAPE = /\\([0-9a-fA-F]{1,6}[ \t\n\r\f]?|[\s\S])/g;
const IMAGE_SET_FUNCTION = /^(-\w+-)?image-set$/i;

const normalizeUrl = (str, isString) => {
// Remove extra spaces and newlines:
Expand Down Expand Up @@ -390,7 +394,7 @@ class CssParser extends Parser {
if (
lastFunction &&
(lastFunction[0].replace(/\\/g, "").toLowerCase() === "url" ||
/^(-\w+-)?image-set$/i.test(lastFunction[0].replace(/\\/g, "")))
IMAGE_SET_FUNCTION.test(lastFunction[0].replace(/\\/g, "")))
) {
let value = normalizeUrl(input.slice(start + 1, end - 1), true);

Expand Down

0 comments on commit d1634b8

Please sign in to comment.