Skip to content

Commit

Permalink
regex correcting
Browse files Browse the repository at this point in the history
  • Loading branch information
39zde committed Nov 14, 2024
1 parent 9a50c76 commit 9767fae
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,}((?<directive>[\"\'][^\s]+[\"\'])[\s]{0,}){1,})(?=;)/, ` 'sha256-${cssHash}'`);
html = html.replace(/(?<=style-src[\s\t]{1,})((?<directive>[\"\'][^\s]+[\"\'])[\s]{0,})+(?=\;)/gm, ` 'sha256-${cssHash}'`);

html = html.replace(sheet.ownerNode.outerHTML, `<style>${css}</style>`);
return html;
Expand Down Expand Up @@ -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,}((?<directive>[\"\'][^\s]+[\"\'])[\s]{0,}){1,})(?=;)/gm, ` 'sha256-${jsHash}'`);
html = html.replace(/(?<=style-src[\s\t]{1,})((?<directive>[\"\'][^\s]+[\"\'])[\s]{0,})+(?=\;)/gm, ` 'sha256-${jsHash}'`);
return html;
}
}
Expand Down

0 comments on commit 9767fae

Please sign in to comment.