🚸 (js) Parse script to content to remove useless script tags if any
This commit is contained in:
@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user