1
0
mirror of https://github.com/chinchang/web-maker.git synced 2025-07-26 16:20:09 +02:00

fix acss config with unquoted keys

This commit is contained in:
Kushagra Gour
2024-02-08 16:37:58 +05:30
parent 33a54766f3
commit e54c2546b1

View File

@@ -132,10 +132,18 @@ export function computeCss(userCode, mode, settings) {
const html = code;
const foundClasses = atomizer.findClassNames(html);
var finalConfig;
// Regular expression to find unquoted keys: looks for word characters (including _) followed by a colon
// and put them in quotes
const fixedConfigJson = (settings.acssConfig || '{}').replace(
/([{,]\s*)([^\s"{:]+)(\s*:\s*)/g,
'$1"$2"$3'
);
try {
finalConfig = atomizer.getConfig(
foundClasses,
JSON.parse(settings.acssConfig)
JSON.parse(fixedConfigJson)
);
} catch (e) {
finalConfig = atomizer.getConfig(foundClasses, {});