We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 87d8099 commit 0a1e72eCopy full SHA for 0a1e72e
1 file changed
components/HTMLBlock.jsx
@@ -7,8 +7,11 @@ const PropTypes = require('prop-types');
7
* @arg {string} html the HTML from which to extract script tags.
8
*/
9
const extractScripts = html => {
10
+ if (typeof window === 'undefined' || !html) return () => {};
11
+
12
const regex = /<script\b[^>]*>([\s\S]*?)<\/script>/gim;
13
const scripts = [...html.matchAll(regex)].map(m => m[1].trim());
14
15
return () => scripts.map(js => window.eval(js));
16
};
17
0 commit comments