requestjs-rails 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/requestjs.js +17 -4
- data/lib/requestjs/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3cfa027194b10b71958ba06f76e28d181ab6df698cbe26afd29295aec86146b5
|
4
|
+
data.tar.gz: 757283047d0579f8e32f8556b90e2b4e24bcda160590cd8de677ba64eb26e88e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c12ab260f0c0a403c2c2666e35386f72c7637e5c33d71a312bf335ad02c90a261b544b211c3b30bdf06ba19fed84a458e77ac8cadb165482d4e44f7bc03b0fa
|
7
|
+
data.tar.gz: c0c5a9d7c6cb5963626672fe2866112fce7a75e11c6baf4edb942d27ff507a23499fda5d3d2f553d942b417ba65ab047ccebac449fbb8357110313de37ed8f54
|
@@ -105,7 +105,7 @@ function stringEntriesFromFormData(formData) {
|
|
105
105
|
function mergeEntries(searchParams, entries) {
|
106
106
|
for (const [name, value] of entries) {
|
107
107
|
if (value instanceof window.File) continue;
|
108
|
-
if (searchParams.has(name)) {
|
108
|
+
if (searchParams.has(name) && !name.includes("[]")) {
|
109
109
|
searchParams.delete(name);
|
110
110
|
searchParams.set(name, value);
|
111
111
|
} else {
|
@@ -143,6 +143,16 @@ class FetchRequest {
|
|
143
143
|
headers[key] = value;
|
144
144
|
this.options.headers = headers;
|
145
145
|
}
|
146
|
+
sameHostname() {
|
147
|
+
if (!this.originalUrl.startsWith("http:")) {
|
148
|
+
return true;
|
149
|
+
}
|
150
|
+
try {
|
151
|
+
return new URL(this.originalUrl).hostname === window.location.hostname;
|
152
|
+
} catch (_) {
|
153
|
+
return true;
|
154
|
+
}
|
155
|
+
}
|
146
156
|
get fetchOptions() {
|
147
157
|
return {
|
148
158
|
method: this.method.toUpperCase(),
|
@@ -154,12 +164,15 @@ class FetchRequest {
|
|
154
164
|
};
|
155
165
|
}
|
156
166
|
get headers() {
|
157
|
-
|
167
|
+
const baseHeaders = {
|
158
168
|
"X-Requested-With": "XMLHttpRequest",
|
159
|
-
"X-CSRF-Token": this.csrfToken,
|
160
169
|
"Content-Type": this.contentType,
|
161
170
|
Accept: this.accept
|
162
|
-
}
|
171
|
+
};
|
172
|
+
if (this.sameHostname()) {
|
173
|
+
baseHeaders["X-CSRF-Token"] = this.csrfToken;
|
174
|
+
}
|
175
|
+
return compact(Object.assign(baseHeaders, this.additionalHeaders));
|
163
176
|
}
|
164
177
|
get csrfToken() {
|
165
178
|
return getCookie(metaContent("csrf-param")) || metaContent("csrf-token");
|
data/lib/requestjs/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: requestjs-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marcelo Lauxen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-11-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -61,7 +61,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
61
61
|
- !ruby/object:Gem::Version
|
62
62
|
version: '0'
|
63
63
|
requirements: []
|
64
|
-
rubygems_version: 3.
|
64
|
+
rubygems_version: 3.1.6
|
65
65
|
signing_key:
|
66
66
|
specification_version: 4
|
67
67
|
summary: A tiny Fetch API wrapper that allows you to make http requests without need
|