From f014a52d99d4b2af88ecc32cf282ad21e86e79b1 Mon Sep 17 00:00:00 2001 From: Arpit Date: Tue, 30 Jul 2024 09:26:40 +0530 Subject: [PATCH] fixes: if references includes includes a template literal (#10464) --- frontend/src/Editor/CodeEditor/utils.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/frontend/src/Editor/CodeEditor/utils.js b/frontend/src/Editor/CodeEditor/utils.js index e3b0536e12..3ce951f644 100644 --- a/frontend/src/Editor/CodeEditor/utils.js +++ b/frontend/src/Editor/CodeEditor/utils.js @@ -225,10 +225,17 @@ const queryHasStringOtherThanVariable = (query) => { const endsWithDoubleCurly = query.endsWith('}}'); if (startsWithDoubleCurly && endsWithDoubleCurly) { - // Extract the content within the curly braces const content = query.slice(2, -2).trim(); - // Check if there is a space within the content - return content.includes(' '); + + if (content.includes(' ')) { + return true; + } + + //* Check if the content includes a template literal + //!Note: Do not delete this regex, it is used to check if the content includes a template literal + //used for cases like {{queries.runjs1.data[0][`${components.textinput1.value}`]}} + const templateLiteralRegex = /\$\{[^}]+\}/; + return templateLiteralRegex.test(content); } return false;