Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
16 lines
733 B
Plaintext
16 lines
733 B
Plaintext
const checkStringStartsWith = (token) => (key) => typeof key === "string" && key.startsWith(token);
|
|
const isCSSVariableName =
|
|
/*@__PURE__*/ checkStringStartsWith("--");
|
|
const startsAsVariableToken =
|
|
/*@__PURE__*/ checkStringStartsWith("var(--");
|
|
const isCSSVariableToken = (value) => {
|
|
const startsWithToken = startsAsVariableToken(value);
|
|
if (!startsWithToken)
|
|
return false;
|
|
// Ensure any comments are stripped from the value as this can harm performance of the regex.
|
|
return singleCssVariableRegex.test(value.split("/*")[0].trim());
|
|
};
|
|
const singleCssVariableRegex = /var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;
|
|
|
|
export { isCSSVariableName, isCSSVariableToken };
|