Skip to content

Commit

Permalink
🚸 (js) Parse script to content to remove useless script tags if any
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed Mar 1, 2023
1 parent 8fb1de1 commit cc07389
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit cc07389

Please sign in to comment.