Skip to content

Commit 0712077

Browse files
Apply suggestions from code review
Co-authored-by: Konnor Rogers <[email protected]>
1 parent 47c5d2f commit 0712077

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/fetch_response.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export class FetchResponse {
6262
}
6363

6464
get isScript () {
65-
return this.contentType.match(/\bjavascript\b/)
65+
return this.contentType.match(/\b(?:java|ecma)script\b/)
6666
}
6767

6868
async renderTurboStream () {
@@ -80,6 +80,9 @@ export class FetchResponse {
8080
async activeScript () {
8181
if (this.isScript) {
8282
const script = document.createElement('script')
83+
const metaTag = document.querySelector("meta[name=csp-nonce]");
84+
const nonce = metaTag && metaTag.content;
85+
if (nonce) { script.setAttribute("nonce", nonce) }
8386
script.innerHTML = await this.text
8487
document.body.appendChild(script)
8588
} else {

0 commit comments

Comments
 (0)