From 7eb1dbd8fac93a7424581dea3dc035d7a539b5db Mon Sep 17 00:00:00 2001 From: Lawren Date: Fri, 22 Nov 2024 09:38:11 -0500 Subject: [PATCH] fix: #564 resolves issue with element.replace on non-string elements --- src/runtime/nitro/plugins/20-subresourceIntegrity.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/runtime/nitro/plugins/20-subresourceIntegrity.ts b/src/runtime/nitro/plugins/20-subresourceIntegrity.ts index 4527bc1b..cd836c07 100644 --- a/src/runtime/nitro/plugins/20-subresourceIntegrity.ts +++ b/src/runtime/nitro/plugins/20-subresourceIntegrity.ts @@ -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) {