From b988cae58c75e1ca64decfe19e76e1ae79d6a704 Mon Sep 17 00:00:00 2001 From: Henry Heng Date: Fri, 4 Apr 2025 16:19:04 +0800 Subject: [PATCH] Bugfix/Prevent transforming double curly brackets (#4252) prevent transforming double curly brackets --- packages/components/src/utils.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/components/src/utils.ts b/packages/components/src/utils.ts index fb29c129..f5bc3f05 100644 --- a/packages/components/src/utils.ts +++ b/packages/components/src/utils.ts @@ -284,14 +284,16 @@ export const getInputVariables = (paramValue: string): string[] => { } /** - * Transform curly braces into double curly braces if the content includes a colon. + * Transform single curly braces into double curly braces if the content includes a colon. * @param input - The original string that may contain { ... } segments. * @returns The transformed string, where { ... } containing a colon has been replaced with {{ ... }}. */ export const transformBracesWithColon = (input: string): string => { - // This regex will match anything of the form `{ ... }` (no nested braces). - // `[^{}]*` means: match any characters that are not `{` or `}` zero or more times. - const regex = /\{([^{}]*?)\}/g + // This regex uses negative lookbehind (? { // groupContent is the text inside the braces `{ ... }`.