fix: handle unquoted @placeholders@ in JSON validation
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user