Skip to content

Commit f0de6b9

Browse files
committed
bump to @rails/[email protected]
1 parent d1a9f1f commit f0de6b9

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

app/assets/javascripts/requestjs.js

+11-5
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,11 @@ class FetchResponse {
6363
if (this.isScript) {
6464
const script = document.createElement("script");
6565
const metaTag = document.querySelector("meta[name=csp-nonce]");
66-
const nonce = metaTag && metaTag.content;
67-
if (nonce) {
68-
script.setAttribute("nonce", nonce);
66+
if (metaTag) {
67+
const nonce = metaTag.nonce === "" ? metaTag.content : metaTag.nonce;
68+
if (nonce) {
69+
script.setAttribute("nonce", nonce);
70+
}
6971
}
7072
script.innerHTML = await this.text;
7173
document.body.appendChild(script);
@@ -166,7 +168,7 @@ class FetchRequest {
166168
this.options.headers = headers;
167169
}
168170
sameHostname() {
169-
if (!this.originalUrl.startsWith("http:")) {
171+
if (!this.originalUrl.startsWith("http:") && !this.originalUrl.startsWith("https:")) {
170172
return true;
171173
}
172174
try {
@@ -182,7 +184,8 @@ class FetchRequest {
182184
body: this.formattedBody,
183185
signal: this.signal,
184186
credentials: this.credentials,
185-
redirect: this.redirect
187+
redirect: this.redirect,
188+
keepalive: this.keepalive
186189
};
187190
}
188191
get headers() {
@@ -260,6 +263,9 @@ class FetchRequest {
260263
get credentials() {
261264
return this.options.credentials || "same-origin";
262265
}
266+
get keepalive() {
267+
return this.options.keepalive || false;
268+
}
263269
get additionalHeaders() {
264270
return this.options.headers || {};
265271
}

0 commit comments

Comments
 (0)