fix: handle unquoted @placeholders@ in JSON validation

This commit is contained in:
sokol
2026-02-19 00:02:43 +03:00
parent 93e3a66252
commit 529b506612

View File

@@ -52,7 +52,13 @@ export function ConfigTemplate(props: ConfigTemplateProps) {
try {
if (value.trim()) {
// Replace @placeholders@ with valid JSON values for validation
const sanitizedValue = value.replace(/"@?(\w+)@?"/g, '"__PLACEHOLDER__"');
// Handle both quoted "@placeholder@" and unquoted @placeholder@
let sanitizedValue = value
// Replace quoted placeholders: "@host@" -> "__PLACEHOLDER__"
.replace(/"@[^"]+@"/g, '"__PLACEHOLDER__"')
// Replace unquoted placeholders between : and , or } : @port@ -> "__PLACEHOLDER__"
.replace(/:\s*@[^,\s}]+@/g, ': "__PLACEHOLDER__"');
JSON.parse(sanitizedValue);
setJsonError(null);
} else {