Skip to content

Commit 493409e

Browse files
committed
Add content nonce meta-tag attribute fallback
1 parent f3460a1 commit 493409e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/fetch_response.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,10 @@ export class FetchResponse {
8181
if (this.isScript) {
8282
const script = document.createElement('script')
8383
const metaTag = document.querySelector('meta[name=csp-nonce]')
84-
const nonce = metaTag && metaTag.content
85-
if (nonce) { script.setAttribute('nonce', nonce) }
84+
if (metaTag) {
85+
const nonce = metaTag.nonce == "" ? metaTag.content : metaTag.nonce
86+
if (nonce) { script.setAttribute('nonce', nonce) }
87+
}
8688
script.innerHTML = await this.text
8789
document.body.appendChild(script)
8890
} else {

0 commit comments

Comments
 (0)