Skip to content

Commit

Permalink
csp appendOffset: use optional chaining
Browse files Browse the repository at this point in the history
  • Loading branch information
gregtwallace committed Mar 26, 2024
1 parent 282f255 commit c495d72
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/vite/src/node/plugins/html.ts
Expand Up @@ -1191,7 +1191,7 @@ export function injectNonceAttributeTagHook(
) {
// if there is no endTag, the end of the startTag will be `/>`
// therefore, the appendOffset should be 2 in this case, instead of 1
const appendOffset = node.sourceCodeLocation.endTag ? 1 : 2
const appendOffset = node?.sourceCodeLocation?.endTag ? 1 : 2

s.appendRight(
node.sourceCodeLocation!.startTag!.endOffset - appendOffset,
Expand Down

0 comments on commit c495d72

Please sign in to comment.