Skip to content

Commit ea24d2d

Browse files
authoredOct 9, 2024··
Merge pull request #79 from codergeek121/rename-csp-meta-tag-attribute
Add content nonce meta-tag attribute fallback
2 parents 7e77fb3 + f9d8834 commit ea24d2d

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)
Please sign in to comment.