-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🚸 (js) Parse script to content to remove useless script tags if any
- Loading branch information
1 parent
8fb1de1
commit cc07389
Showing
1 changed file
with
8 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |