diff --git a/components/HTMLBlock.jsx b/components/HTMLBlock.jsx index ca66c4619..bdff42661 100644 --- a/components/HTMLBlock.jsx +++ b/components/HTMLBlock.jsx @@ -7,8 +7,11 @@ const PropTypes = require('prop-types'); * @arg {string} html the HTML from which to extract script tags. */ const extractScripts = html => { + if (typeof window === 'undefined' || !html) return () => {}; + const regex = /]*>([\s\S]*?)<\/script>/gim; const scripts = [...html.matchAll(regex)].map(m => m[1].trim()); + return () => scripts.map(js => window.eval(js)); };