Skip to content

Commit ae5dc62

Browse files
committed
Improve validate-constant scriptlet helper
Add support for `json:`-prefixed values.
1 parent b1f28b4 commit ae5dc62

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

assets/resources/scriptlets.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,9 @@ function validateConstantFn(trusted, raw, extraArgs = {}) {
531531
if ( isNaN(raw) ) { return; }
532532
if ( Math.abs(raw) > 0x7FFF ) { return; }
533533
} else if ( trusted ) {
534-
if ( raw.startsWith('{') && raw.endsWith('}') ) {
534+
if ( raw.startsWith('json:') ) {
535+
try { value = safe.JSON_parse(raw.slice(5)); } catch(ex) { return; }
536+
} else if ( raw.startsWith('{') && raw.endsWith('}') ) {
535537
try { value = safe.JSON_parse(raw).value; } catch(ex) { return; }
536538
}
537539
} else {

0 commit comments

Comments
 (0)