Skip to content

Commit

Permalink
Merge pull request #567 from lawren/issue-564
Browse files Browse the repository at this point in the history
fix: #564 resolves issue with element.replace on non-string elements
  • Loading branch information
vejja authored Nov 22, 2024
2 parents 0146182 + 7eb1dbd commit 938e859
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/runtime/nitro/plugins/20-subresourceIntegrity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ export default defineNitroPlugin((nitroApp) => {
const sections = ['body', 'bodyAppend', 'bodyPrepend', 'head'] as Section[]
for (const section of sections) {
html[section] = html[section].map(element => {
// Skip non-string elements
if (typeof element !== 'string') {
return element;
}

element = element.replace(SCRIPT_RE, (match, rest: string, src: string) => {
const hash = sriHashes[src]
if (hash) {
Expand Down

0 comments on commit 938e859

Please sign in to comment.