diff --git a/index.js b/index.js index 6805203..69a56c6 100644 --- a/index.js +++ b/index.js @@ -308,7 +308,7 @@ class UtilityFunctions { if (!cssHash) { throw new Error("Failed to update CSP for style-src"); } - html = html.replace(/(?<=style-src[\s\t]{1,})((?[\"\'][^\s]+[\"\'])[\s]{0,})+(?=\;)/gm, ` 'sha256-${cssHash}'`); + html = html.replace(/style-src[\s\t]{1,}((?[\"\'][^\s]+[\"\'])[\s]{0,})+(?=\;)/gm, `style-src-elem 'sha256-${cssHash}'`); html = html.replace(sheet.ownerNode.outerHTML, ``); return html; @@ -380,7 +380,7 @@ class UtilityFunctions { throw new Error("Failed to update CSP for script-src"); } // update the csp - html = html.replace(/(?<=script-src[\s\t]{1,})((?[\"\'][^\s]+[\"\'])[\s]{0,})+(?=\;)/gm, ` 'sha256-${jsHash}'`); + html = html.replace(/script-src[\s\t]{1,}((?[\"\'][^\s]+[\"\'])[\s]{0,})+(?=\;)/gm, `script-src-elem 'sha256-${jsHash}'`); return html; } }