2
0

🚸 (js) Parse script to content to remove useless script tags if any

This commit is contained in:
Baptiste Arnaud
2023-03-01 14:33:59 +01:00
parent 8fb1de1dc5
commit cc07389c37

View File

@ -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(/<script>/g, '')
.replace(/<\/script>/g, '')
return contentWithoutScriptTags
}