axios 1.10.0 → 1.11.0
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.
- package/CHANGELOG.md +17 -0
- package/README.md +1 -4
- package/dist/axios.js +39 -5
- package/dist/axios.js.map +1 -1
- package/dist/axios.min.js +2 -2
- package/dist/axios.min.js.map +1 -1
- package/dist/browser/axios.cjs +46 -9
- package/dist/browser/axios.cjs.map +1 -1
- package/dist/esm/axios.js +46 -9
- package/dist/esm/axios.js.map +1 -1
- package/dist/esm/axios.min.js +2 -2
- package/dist/esm/axios.min.js.map +1 -1
- package/dist/node/axios.cjs +46 -9
- package/dist/node/axios.cjs.map +1 -1
- package/index.d.cts +13 -2
- package/lib/core/Axios.js +2 -2
- package/lib/core/mergeConfig.js +1 -1
- package/lib/env/data.js +1 -1
- package/lib/helpers/throttle.js +1 -1
- package/lib/helpers/toURLEncodedForm.js +4 -3
- package/lib/utils.js +36 -0
- package/package.json +5 -5
package/index.d.cts
CHANGED
|
@@ -6,7 +6,7 @@ type MethodsHeaders = Partial<{
|
|
|
6
6
|
[Key in axios.Method as Lowercase<Key>]: AxiosHeaders;
|
|
7
7
|
} & {common: AxiosHeaders}>;
|
|
8
8
|
|
|
9
|
-
type AxiosHeaderMatcher = (this: AxiosHeaders, value: string, name: string
|
|
9
|
+
type AxiosHeaderMatcher = string | RegExp | ((this: AxiosHeaders, value: string, name: string) => boolean);
|
|
10
10
|
|
|
11
11
|
type AxiosHeaderParser = (this: AxiosHeaders, value: axios.AxiosHeaderValue, header: string) => any;
|
|
12
12
|
|
|
@@ -77,6 +77,8 @@ declare class AxiosHeaders {
|
|
|
77
77
|
getAuthorization(matcher?: AxiosHeaderMatcher): axios.AxiosHeaderValue;
|
|
78
78
|
hasAuthorization(matcher?: AxiosHeaderMatcher): boolean;
|
|
79
79
|
|
|
80
|
+
getSetCookie(): string[];
|
|
81
|
+
|
|
80
82
|
[Symbol.iterator](): IterableIterator<[string, axios.AxiosHeaderValue]>;
|
|
81
83
|
}
|
|
82
84
|
|
|
@@ -97,6 +99,14 @@ declare class AxiosError<T = unknown, D = any> extends Error {
|
|
|
97
99
|
status?: number;
|
|
98
100
|
toJSON: () => object;
|
|
99
101
|
cause?: Error;
|
|
102
|
+
static from<T = unknown, D = any>(
|
|
103
|
+
error: Error | unknown,
|
|
104
|
+
code?: string,
|
|
105
|
+
config?: axios.InternalAxiosRequestConfig<D>,
|
|
106
|
+
request?: any,
|
|
107
|
+
response?: axios.AxiosResponse<T, D>,
|
|
108
|
+
customProps?: object,
|
|
109
|
+
): AxiosError<T, D>;
|
|
100
110
|
static readonly ERR_FR_TOO_MANY_REDIRECTS = "ERR_FR_TOO_MANY_REDIRECTS";
|
|
101
111
|
static readonly ERR_BAD_OPTION_VALUE = "ERR_BAD_OPTION_VALUE";
|
|
102
112
|
static readonly ERR_BAD_OPTION = "ERR_BAD_OPTION";
|
|
@@ -424,7 +434,7 @@ declare namespace axios {
|
|
|
424
434
|
// Alias
|
|
425
435
|
type RawAxiosRequestConfig<D = any> = AxiosRequestConfig<D>;
|
|
426
436
|
|
|
427
|
-
interface InternalAxiosRequestConfig<D = any> extends AxiosRequestConfig {
|
|
437
|
+
interface InternalAxiosRequestConfig<D = any> extends AxiosRequestConfig<D> {
|
|
428
438
|
headers: AxiosRequestHeaders;
|
|
429
439
|
}
|
|
430
440
|
|
|
@@ -542,6 +552,7 @@ declare namespace axios {
|
|
|
542
552
|
formToJSON(form: GenericFormData|GenericHTMLFormElement): object;
|
|
543
553
|
getAdapter(adapters: AxiosAdapterConfig | AxiosAdapterConfig[] | undefined): AxiosAdapter;
|
|
544
554
|
AxiosHeaders: typeof AxiosHeaders;
|
|
555
|
+
mergeConfig<D = any>(config1: AxiosRequestConfig<D>, config2: AxiosRequestConfig<D>): AxiosRequestConfig<D>;
|
|
545
556
|
}
|
|
546
557
|
}
|
|
547
558
|
|
package/lib/core/Axios.js
CHANGED
|
@@ -153,8 +153,8 @@ class Axios {
|
|
|
153
153
|
|
|
154
154
|
if (!synchronousRequestInterceptors) {
|
|
155
155
|
const chain = [dispatchRequest.bind(this), undefined];
|
|
156
|
-
chain.unshift
|
|
157
|
-
chain.push
|
|
156
|
+
chain.unshift(...requestInterceptorChain);
|
|
157
|
+
chain.push(...responseInterceptorChain);
|
|
158
158
|
len = chain.length;
|
|
159
159
|
|
|
160
160
|
promise = Promise.resolve(config);
|
package/lib/core/mergeConfig.js
CHANGED
|
@@ -96,7 +96,7 @@ export default function mergeConfig(config1, config2) {
|
|
|
96
96
|
headers: (a, b , prop) => mergeDeepProperties(headersToObject(a), headersToObject(b),prop, true)
|
|
97
97
|
};
|
|
98
98
|
|
|
99
|
-
utils.forEach(Object.keys(
|
|
99
|
+
utils.forEach(Object.keys({...config1, ...config2}), function computeConfigValue(prop) {
|
|
100
100
|
const merge = mergeMap[prop] || mergeDeepProperties;
|
|
101
101
|
const configValue = merge(config1[prop], config2[prop], prop);
|
|
102
102
|
(utils.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
|
package/lib/env/data.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "1.
|
|
1
|
+
export const VERSION = "1.11.0";
|
package/lib/helpers/throttle.js
CHANGED
|
@@ -5,7 +5,7 @@ import toFormData from './toFormData.js';
|
|
|
5
5
|
import platform from '../platform/index.js';
|
|
6
6
|
|
|
7
7
|
export default function toURLEncodedForm(data, options) {
|
|
8
|
-
return toFormData(data, new platform.classes.URLSearchParams(),
|
|
8
|
+
return toFormData(data, new platform.classes.URLSearchParams(), {
|
|
9
9
|
visitor: function(value, key, path, helpers) {
|
|
10
10
|
if (platform.isNode && utils.isBuffer(value)) {
|
|
11
11
|
this.append(key, value.toString('base64'));
|
|
@@ -13,6 +13,7 @@ export default function toURLEncodedForm(data, options) {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
return helpers.defaultVisitor.apply(this, arguments);
|
|
16
|
-
}
|
|
17
|
-
|
|
16
|
+
},
|
|
17
|
+
...options
|
|
18
|
+
});
|
|
18
19
|
}
|
package/lib/utils.js
CHANGED
|
@@ -136,6 +136,27 @@ const isPlainObject = (val) => {
|
|
|
136
136
|
return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(toStringTag in val) && !(iterator in val);
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
+
/**
|
|
140
|
+
* Determine if a value is an empty object (safely handles Buffers)
|
|
141
|
+
*
|
|
142
|
+
* @param {*} val The value to test
|
|
143
|
+
*
|
|
144
|
+
* @returns {boolean} True if value is an empty object, otherwise false
|
|
145
|
+
*/
|
|
146
|
+
const isEmptyObject = (val) => {
|
|
147
|
+
// Early return for non-objects or Buffers to prevent RangeError
|
|
148
|
+
if (!isObject(val) || isBuffer(val)) {
|
|
149
|
+
return false;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
try {
|
|
153
|
+
return Object.keys(val).length === 0 && Object.getPrototypeOf(val) === Object.prototype;
|
|
154
|
+
} catch (e) {
|
|
155
|
+
// Fallback for any other objects that might cause RangeError with Object.keys()
|
|
156
|
+
return false;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
139
160
|
/**
|
|
140
161
|
* Determine if a value is a Date
|
|
141
162
|
*
|
|
@@ -258,6 +279,11 @@ function forEach(obj, fn, {allOwnKeys = false} = {}) {
|
|
|
258
279
|
fn.call(null, obj[i], i, obj);
|
|
259
280
|
}
|
|
260
281
|
} else {
|
|
282
|
+
// Buffer check
|
|
283
|
+
if (isBuffer(obj)) {
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
|
|
261
287
|
// Iterate over object keys
|
|
262
288
|
const keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
|
|
263
289
|
const len = keys.length;
|
|
@@ -271,6 +297,10 @@ function forEach(obj, fn, {allOwnKeys = false} = {}) {
|
|
|
271
297
|
}
|
|
272
298
|
|
|
273
299
|
function findKey(obj, key) {
|
|
300
|
+
if (isBuffer(obj)){
|
|
301
|
+
return null;
|
|
302
|
+
}
|
|
303
|
+
|
|
274
304
|
key = key.toLowerCase();
|
|
275
305
|
const keys = Object.keys(obj);
|
|
276
306
|
let i = keys.length;
|
|
@@ -624,6 +654,11 @@ const toJSONObject = (obj) => {
|
|
|
624
654
|
return;
|
|
625
655
|
}
|
|
626
656
|
|
|
657
|
+
//Buffer check
|
|
658
|
+
if (isBuffer(source)) {
|
|
659
|
+
return source;
|
|
660
|
+
}
|
|
661
|
+
|
|
627
662
|
if(!('toJSON' in source)) {
|
|
628
663
|
stack[i] = source;
|
|
629
664
|
const target = isArray(source) ? [] : {};
|
|
@@ -695,6 +730,7 @@ export default {
|
|
|
695
730
|
isBoolean,
|
|
696
731
|
isObject,
|
|
697
732
|
isPlainObject,
|
|
733
|
+
isEmptyObject,
|
|
698
734
|
isReadableStream,
|
|
699
735
|
isRequest,
|
|
700
736
|
isResponse,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "axios",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.11.0",
|
|
4
4
|
"description": "Promise based HTTP client for the browser and node.js",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"exports": {
|
|
@@ -157,7 +157,7 @@
|
|
|
157
157
|
"typings": "./index.d.ts",
|
|
158
158
|
"dependencies": {
|
|
159
159
|
"follow-redirects": "^1.15.6",
|
|
160
|
-
"form-data": "^4.0.
|
|
160
|
+
"form-data": "^4.0.4",
|
|
161
161
|
"proxy-from-env": "^1.1.0"
|
|
162
162
|
},
|
|
163
163
|
"bundlesize": [
|
|
@@ -176,10 +176,10 @@
|
|
|
176
176
|
"Justin Beckwith (https://github.com/JustinBeckwith)",
|
|
177
177
|
"Martti Laine (https://github.com/codeclown)",
|
|
178
178
|
"Xianming Zhong (https://github.com/chinesedfan)",
|
|
179
|
-
"Rikki Gibson (https://github.com/RikkiGibson)",
|
|
180
179
|
"Remco Haszing (https://github.com/remcohaszing)",
|
|
181
|
-
"
|
|
182
|
-
"Ben Carp (https://github.com/carpben)"
|
|
180
|
+
"Rikki Gibson (https://github.com/RikkiGibson)",
|
|
181
|
+
"Ben Carp (https://github.com/carpben)",
|
|
182
|
+
"Yasu Flores (https://github.com/yasuf)"
|
|
183
183
|
],
|
|
184
184
|
"sideEffects": false,
|
|
185
185
|
"release-it": {
|