1
0
mirror of https://github.com/chinchang/web-maker.git synced 2025-07-27 00:30: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 html = code;
const foundClasses = atomizer.findClassNames(html); const foundClasses = atomizer.findClassNames(html);
var finalConfig; 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 { try {
finalConfig = atomizer.getConfig( finalConfig = atomizer.getConfig(
foundClasses, foundClasses,
JSON.parse(settings.acssConfig) JSON.parse(fixedConfigJson)
); );
} catch (e) { } catch (e) {
finalConfig = atomizer.getConfig(foundClasses, {}); finalConfig = atomizer.getConfig(foundClasses, {});