There was an error while loading. Please reload this page.
1 parent f1e67b6 commit 3c85c6bCopy full SHA for 3c85c6b
1 file changed
packages/vite/src/node/plugins/html.ts
@@ -1189,8 +1189,13 @@ export function injectNonceAttributeTagHook(
1189
parseRelAttr(attr.value).some((a)=>processRelType.has(a)),
1190
))
1191
){
1192
+// if the closing of the start tag includes a `/`, the offset should be 2 so the nonce
1193
+// is appended prior to the `/`
1194
+constappendOffset=
1195
+html[node.sourceCodeLocation!.startTag!.endOffset-2]==='/' ? 2 : 1
1196
+
1197
s.appendRight(
-node.sourceCodeLocation!.startTag!.endOffset-1,
1198
+node.sourceCodeLocation!.startTag!.endOffset-appendOffset,
1199
` nonce="${nonce}"`,
1200
)
1201
}
0 commit comments