axios 1.6.0 → 1.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of axios might be problematic. Click here for more details.
- package/CHANGELOG.md +13 -0
- package/dist/axios.js +189 -130
- package/dist/axios.js.map +1 -1
- package/dist/axios.min.js +1 -1
- package/dist/axios.min.js.map +1 -1
- package/dist/browser/axios.cjs +141 -139
- package/dist/browser/axios.cjs.map +1 -1
- package/dist/esm/axios.js +141 -139
- package/dist/esm/axios.js.map +1 -1
- package/dist/esm/axios.min.js +1 -1
- package/dist/esm/axios.min.js.map +1 -1
- package/dist/node/axios.cjs +204 -151
- package/dist/node/axios.cjs.map +1 -1
- package/lib/adapters/xhr.js +5 -6
- package/lib/env/data.js +1 -1
- package/lib/helpers/cookies.js +1 -1
- package/lib/helpers/isURLSameOrigin.js +1 -1
- package/lib/platform/browser/index.js +0 -51
- package/lib/platform/common/utils.js +47 -0
- package/lib/platform/index.js +5 -1
- package/package.json +2 -1
package/lib/adapters/xhr.js
CHANGED
@@ -64,13 +64,12 @@ export default isXHRAdapterSupported && function (config) {
|
|
64
64
|
let contentType;
|
65
65
|
|
66
66
|
if (utils.isFormData(requestData)) {
|
67
|
-
if (platform.
|
67
|
+
if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv) {
|
68
68
|
requestHeaders.setContentType(false); // Let the browser set it
|
69
|
-
} else if(
|
70
|
-
requestHeaders.setContentType('multipart/form-data'); // mobile/desktop app frameworks
|
71
|
-
} else if(utils.isString(contentType = requestHeaders.getContentType())){
|
69
|
+
} else if ((contentType = requestHeaders.getContentType()) !== false) {
|
72
70
|
// fix semicolon duplication issue for ReactNative FormData implementation
|
73
|
-
|
71
|
+
const [type, ...tokens] = contentType ? contentType.split(';').map(token => token.trim()).filter(Boolean) : [];
|
72
|
+
requestHeaders.setContentType([type || 'multipart/form-data', ...tokens].join('; '));
|
74
73
|
}
|
75
74
|
}
|
76
75
|
|
@@ -186,7 +185,7 @@ export default isXHRAdapterSupported && function (config) {
|
|
186
185
|
// Add xsrf header
|
187
186
|
// This is only done if running in a standard browser environment.
|
188
187
|
// Specifically not if we're in a web worker, or react-native.
|
189
|
-
if (platform.
|
188
|
+
if (platform.hasStandardBrowserEnv) {
|
190
189
|
// Add xsrf header
|
191
190
|
// regarding CVE-2023-45857 config.withCredentials condition was removed temporarily
|
192
191
|
const xsrfValue = isURLSameOrigin(fullPath) && config.xsrfCookieName && cookies.read(config.xsrfCookieName);
|
package/lib/env/data.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export const VERSION = "1.6.
|
1
|
+
export const VERSION = "1.6.1";
|
package/lib/helpers/cookies.js
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
import utils from './../utils.js';
|
4
4
|
import platform from '../platform/index.js';
|
5
5
|
|
6
|
-
export default platform.
|
6
|
+
export default platform.hasStandardBrowserEnv ?
|
7
7
|
|
8
8
|
// Standard browser envs support document.cookie
|
9
9
|
(function standardBrowserEnv() {
|
@@ -3,7 +3,7 @@
|
|
3
3
|
import utils from './../utils.js';
|
4
4
|
import platform from '../platform/index.js';
|
5
5
|
|
6
|
-
export default platform.
|
6
|
+
export default platform.hasStandardBrowserEnv ?
|
7
7
|
|
8
8
|
// Standard browser envs have full support of the APIs needed to test
|
9
9
|
// whether the request URL is of the same origin as current location.
|
@@ -2,55 +2,6 @@ import URLSearchParams from './classes/URLSearchParams.js'
|
|
2
2
|
import FormData from './classes/FormData.js'
|
3
3
|
import Blob from './classes/Blob.js'
|
4
4
|
|
5
|
-
/**
|
6
|
-
* Determine if we're running in a standard browser environment
|
7
|
-
*
|
8
|
-
* This allows axios to run in a web worker, and react-native.
|
9
|
-
* Both environments support XMLHttpRequest, but not fully standard globals.
|
10
|
-
*
|
11
|
-
* web workers:
|
12
|
-
* typeof window -> undefined
|
13
|
-
* typeof document -> undefined
|
14
|
-
*
|
15
|
-
* react-native:
|
16
|
-
* navigator.product -> 'ReactNative'
|
17
|
-
* nativescript
|
18
|
-
* navigator.product -> 'NativeScript' or 'NS'
|
19
|
-
*
|
20
|
-
* @returns {boolean}
|
21
|
-
*/
|
22
|
-
const isStandardBrowserEnv = (() => {
|
23
|
-
let product;
|
24
|
-
if (typeof navigator !== 'undefined' && (
|
25
|
-
(product = navigator.product) === 'ReactNative' ||
|
26
|
-
product === 'NativeScript' ||
|
27
|
-
product === 'NS')
|
28
|
-
) {
|
29
|
-
return false;
|
30
|
-
}
|
31
|
-
|
32
|
-
return typeof window !== 'undefined' && typeof document !== 'undefined';
|
33
|
-
})();
|
34
|
-
|
35
|
-
/**
|
36
|
-
* Determine if we're running in a standard browser webWorker environment
|
37
|
-
*
|
38
|
-
* Although the `isStandardBrowserEnv` method indicates that
|
39
|
-
* `allows axios to run in a web worker`, the WebWorker will still be
|
40
|
-
* filtered out due to its judgment standard
|
41
|
-
* `typeof window !== 'undefined' && typeof document !== 'undefined'`.
|
42
|
-
* This leads to a problem when axios post `FormData` in webWorker
|
43
|
-
*/
|
44
|
-
const isStandardBrowserWebWorkerEnv = (() => {
|
45
|
-
return (
|
46
|
-
typeof WorkerGlobalScope !== 'undefined' &&
|
47
|
-
// eslint-disable-next-line no-undef
|
48
|
-
self instanceof WorkerGlobalScope &&
|
49
|
-
typeof self.importScripts === 'function'
|
50
|
-
);
|
51
|
-
})();
|
52
|
-
|
53
|
-
|
54
5
|
export default {
|
55
6
|
isBrowser: true,
|
56
7
|
classes: {
|
@@ -58,7 +9,5 @@ export default {
|
|
58
9
|
FormData,
|
59
10
|
Blob
|
60
11
|
},
|
61
|
-
isStandardBrowserEnv,
|
62
|
-
isStandardBrowserWebWorkerEnv,
|
63
12
|
protocols: ['http', 'https', 'file', 'blob', 'url', 'data']
|
64
13
|
};
|
@@ -0,0 +1,47 @@
|
|
1
|
+
const hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'undefined';
|
2
|
+
|
3
|
+
/**
|
4
|
+
* Determine if we're running in a standard browser environment
|
5
|
+
*
|
6
|
+
* This allows axios to run in a web worker, and react-native.
|
7
|
+
* Both environments support XMLHttpRequest, but not fully standard globals.
|
8
|
+
*
|
9
|
+
* web workers:
|
10
|
+
* typeof window -> undefined
|
11
|
+
* typeof document -> undefined
|
12
|
+
*
|
13
|
+
* react-native:
|
14
|
+
* navigator.product -> 'ReactNative'
|
15
|
+
* nativescript
|
16
|
+
* navigator.product -> 'NativeScript' or 'NS'
|
17
|
+
*
|
18
|
+
* @returns {boolean}
|
19
|
+
*/
|
20
|
+
const hasStandardBrowserEnv = (
|
21
|
+
(product) => {
|
22
|
+
return hasBrowserEnv && ['ReactNative', 'NativeScript', 'NS'].indexOf(product) < 0
|
23
|
+
})(typeof navigator !== 'undefined' && navigator.product);
|
24
|
+
|
25
|
+
/**
|
26
|
+
* Determine if we're running in a standard browser webWorker environment
|
27
|
+
*
|
28
|
+
* Although the `isStandardBrowserEnv` method indicates that
|
29
|
+
* `allows axios to run in a web worker`, the WebWorker will still be
|
30
|
+
* filtered out due to its judgment standard
|
31
|
+
* `typeof window !== 'undefined' && typeof document !== 'undefined'`.
|
32
|
+
* This leads to a problem when axios post `FormData` in webWorker
|
33
|
+
*/
|
34
|
+
const hasStandardBrowserWebWorkerEnv = (() => {
|
35
|
+
return (
|
36
|
+
typeof WorkerGlobalScope !== 'undefined' &&
|
37
|
+
// eslint-disable-next-line no-undef
|
38
|
+
self instanceof WorkerGlobalScope &&
|
39
|
+
typeof self.importScripts === 'function'
|
40
|
+
);
|
41
|
+
})();
|
42
|
+
|
43
|
+
export {
|
44
|
+
hasBrowserEnv,
|
45
|
+
hasStandardBrowserWebWorkerEnv,
|
46
|
+
hasStandardBrowserEnv
|
47
|
+
}
|
package/lib/platform/index.js
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "axios",
|
3
|
-
"version": "1.6.
|
3
|
+
"version": "1.6.1",
|
4
4
|
"description": "Promise based HTTP client for the browser and node.js",
|
5
5
|
"main": "index.js",
|
6
6
|
"exports": {
|
@@ -121,6 +121,7 @@
|
|
121
121
|
"karma-sauce-launcher": "^4.3.6",
|
122
122
|
"karma-sinon": "^1.0.5",
|
123
123
|
"karma-sourcemap-loader": "^0.3.8",
|
124
|
+
"memoizee": "^0.4.15",
|
124
125
|
"minimist": "^1.2.7",
|
125
126
|
"mocha": "^10.0.0",
|
126
127
|
"multer": "^1.4.4",
|