From cc07389c37e1008dc5041bb22162bfc69fd5eac4 Mon Sep 17 00:00:00 2001 From: Baptiste Arnaud Date: Wed, 1 Mar 2023 14:33:59 +0100 Subject: [PATCH] :children_crossing: (js) Parse script to content to remove useless script tags if any --- .../js/src/features/blocks/logic/script/executeScript.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/js/src/features/blocks/logic/script/executeScript.ts b/packages/js/src/features/blocks/logic/script/executeScript.ts index 36342cec1..ee8c4cccb 100644 --- a/packages/js/src/features/blocks/logic/script/executeScript.ts +++ b/packages/js/src/features/blocks/logic/script/executeScript.ts @@ -1,10 +1,17 @@ import type { ScriptToExecute } from 'models' export const executeScript = async ({ content, args }: ScriptToExecute) => { - const func = Function(...args.map((arg) => arg.id), content) + const func = Function(...args.map((arg) => arg.id), parseContent(content)) try { await func(...args.map((arg) => arg.value)) } catch (err) { console.error(err) } } + +const parseContent = (content: string) => { + const contentWithoutScriptTags = content + .replace(/