axios 0.34.0 → 0.35.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/dist/axios.js +241 -25
- package/dist/axios.js.map +1 -1
- package/dist/axios.min.js +1 -1
- package/dist/axios.min.js.map +1 -1
- package/dist/esm/axios.js +241 -25
- 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/lib/adapters/http.js +53 -9
- package/lib/core/Axios.js +29 -14
- package/lib/core/mergeConfig.js +3 -0
- package/lib/env/data.js +1 -1
- package/lib/helpers/assertParamsDepth.js +100 -0
- package/lib/helpers/estimateDataURLDecodedBytes.js +3 -3
- package/lib/helpers/formDataToJSON.js +40 -3
- package/lib/helpers/getDirectAgent.js +85 -0
- package/lib/helpers/shouldBypassProxy.js +17 -1
- package/lib/helpers/toFormData.js +4 -4
- package/lib/utils.js +68 -2
- package/package.json +1 -1
package/dist/esm/axios.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// axios v0.
|
|
1
|
+
// axios v0.35.0 Copyright (c) 2026 Matt Zabriskie
|
|
2
2
|
var bind = function bind(fn, thisArg) {
|
|
3
3
|
return function wrap() {
|
|
4
4
|
return fn.apply(thisArg, arguments);
|
|
@@ -511,10 +511,75 @@ function toArray(thing) {
|
|
|
511
511
|
if (!thing) return null;
|
|
512
512
|
if (isArray(thing)) return thing;
|
|
513
513
|
var i = thing.length;
|
|
514
|
-
if (
|
|
514
|
+
if (typeof i !== 'number' || i < 0 || i > 0xffffffff || Math.floor(i) !== i) return null;
|
|
515
|
+
|
|
516
|
+
// Legacy FileList hosts expose indexed reads without reflecting their keys.
|
|
517
|
+
if (isFileList(thing)) {
|
|
518
|
+
var files = [];
|
|
519
|
+
while (i-- > 0) {
|
|
520
|
+
var file = thing[i];
|
|
521
|
+
if (file === null || isUndefined(file)) return null;
|
|
522
|
+
defineOwnProperty(files, i, file);
|
|
523
|
+
}
|
|
524
|
+
return files;
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
// Count actual indexes, including hidden collection properties, before
|
|
528
|
+
// allocating from the declared length. Box primitives for ES5 object APIs.
|
|
529
|
+
var source = Object(thing);
|
|
530
|
+
var indexes = Object.create(null);
|
|
531
|
+
var count = 0;
|
|
532
|
+
var seen = [];
|
|
533
|
+
var owns = Object.prototype.hasOwnProperty;
|
|
534
|
+
|
|
535
|
+
while (source && count < i) {
|
|
536
|
+
if (seen.indexOf(source) !== -1) return null;
|
|
537
|
+
defineOwnProperty(seen, seen.length, source);
|
|
538
|
+
|
|
539
|
+
if (source === Object.prototype) break;
|
|
540
|
+
|
|
541
|
+
var prototype = Object.getPrototypeOf(source);
|
|
542
|
+
if (prototype === null) {
|
|
543
|
+
var constructorDescriptor = Object.getOwnPropertyDescriptor(source, 'constructor');
|
|
544
|
+
var constructorValue = constructorDescriptor && owns.call(constructorDescriptor, 'value') &&
|
|
545
|
+
constructorDescriptor.value;
|
|
546
|
+
var constructorPrototype = typeof constructorValue === 'function' &&
|
|
547
|
+
Object.getOwnPropertyDescriptor(constructorValue, 'prototype');
|
|
548
|
+
|
|
549
|
+
// Recognize another realm's Object.prototype without excluding
|
|
550
|
+
// application-defined null-prototype parents or invoking accessors.
|
|
551
|
+
if (
|
|
552
|
+
constructorPrototype && owns.call(constructorPrototype, 'value') &&
|
|
553
|
+
constructorPrototype.value === source &&
|
|
554
|
+
Function.prototype.toString.call(constructorValue) === Function.prototype.toString.call(Object)
|
|
555
|
+
) {
|
|
556
|
+
break;
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
var keys = Object.getOwnPropertyNames(source);
|
|
561
|
+
for (var j = 0; j < keys.length; j++) {
|
|
562
|
+
var key = keys[j];
|
|
563
|
+
var index = +key;
|
|
564
|
+
if (
|
|
565
|
+
index >= 0 &&
|
|
566
|
+
index < i &&
|
|
567
|
+
Math.floor(index) === index &&
|
|
568
|
+
String(index) === key &&
|
|
569
|
+
owns.call(source, key) &&
|
|
570
|
+
!indexes[key]
|
|
571
|
+
) {
|
|
572
|
+
indexes[key] = true;
|
|
573
|
+
count++;
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
source = prototype;
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
if (count !== i) return null;
|
|
515
580
|
var arr = new Array(i);
|
|
516
581
|
while (i-- > 0) {
|
|
517
|
-
arr
|
|
582
|
+
defineOwnProperty(arr, i, thing[i]);
|
|
518
583
|
}
|
|
519
584
|
return arr;
|
|
520
585
|
}
|
|
@@ -584,6 +649,7 @@ var utils = {
|
|
|
584
649
|
trim: trim,
|
|
585
650
|
stripBOM: stripBOM,
|
|
586
651
|
inherits: inherits,
|
|
652
|
+
defineOwnProperty: defineOwnProperty,
|
|
587
653
|
toFlatObject: toFlatObject,
|
|
588
654
|
kindOf: kindOf,
|
|
589
655
|
kindOfTest: kindOfTest,
|
|
@@ -905,7 +971,7 @@ function toFormData(obj, formData, options) {
|
|
|
905
971
|
return;
|
|
906
972
|
}
|
|
907
973
|
|
|
908
|
-
stack.
|
|
974
|
+
utils.defineOwnProperty(stack, stack.length, value);
|
|
909
975
|
|
|
910
976
|
utils.forEach(value, function each(el) {
|
|
911
977
|
assertValueDepth(el, depth + 1);
|
|
@@ -934,8 +1000,8 @@ function toFormData(obj, formData, options) {
|
|
|
934
1000
|
value = JSON.stringify(value);
|
|
935
1001
|
} else if (
|
|
936
1002
|
(utils.isArray(value) && isFlatArray(value)) ||
|
|
937
|
-
(utils.isFileList(value) || utils.endsWith(key, '[]') && (arr = utils.toArray(value))
|
|
938
|
-
|
|
1003
|
+
((utils.isFileList(value) || utils.endsWith(key, '[]')) && (arr = utils.toArray(value)))
|
|
1004
|
+
) {
|
|
939
1005
|
// eslint-disable-next-line no-param-reassign
|
|
940
1006
|
key = removeBrackets(key);
|
|
941
1007
|
|
|
@@ -982,7 +1048,7 @@ function toFormData(obj, formData, options) {
|
|
|
982
1048
|
throw Error('Circular reference detected in ' + path.join('.'));
|
|
983
1049
|
}
|
|
984
1050
|
|
|
985
|
-
stack.
|
|
1051
|
+
utils.defineOwnProperty(stack, stack.length, value);
|
|
986
1052
|
|
|
987
1053
|
utils.forEach(value, function each(el, key) {
|
|
988
1054
|
var result = !(utils.isUndefined(el) || el === null) && visitor.call(
|
|
@@ -1254,13 +1320,50 @@ function arrayToObject(arr) {
|
|
|
1254
1320
|
return obj;
|
|
1255
1321
|
}
|
|
1256
1322
|
|
|
1323
|
+
function normalizeArray(value) {
|
|
1324
|
+
if (!utils.isArray(value)) return value;
|
|
1325
|
+
|
|
1326
|
+
var keys = Object.keys(value);
|
|
1327
|
+
if (keys.length !== value.length) return arrayToObject(value);
|
|
1328
|
+
|
|
1329
|
+
for (var i = 0; i < keys.length; i++) {
|
|
1330
|
+
var index = +keys[i];
|
|
1331
|
+
if (
|
|
1332
|
+
index < 0 || index >= value.length ||
|
|
1333
|
+
Math.floor(index) !== index || String(index) !== keys[i]
|
|
1334
|
+
) {
|
|
1335
|
+
return arrayToObject(value);
|
|
1336
|
+
}
|
|
1337
|
+
}
|
|
1338
|
+
|
|
1339
|
+
return value;
|
|
1340
|
+
}
|
|
1341
|
+
|
|
1342
|
+
function normalizeArrays(obj) {
|
|
1343
|
+
var pending = [obj];
|
|
1344
|
+
function normalizeEntry(target, key) {
|
|
1345
|
+
var value = target[key] = normalizeArray(target[key]);
|
|
1346
|
+
if (utils.isArray(value) || utils.isPlainObject(value)) {
|
|
1347
|
+
pending.push(value);
|
|
1348
|
+
}
|
|
1349
|
+
}
|
|
1350
|
+
while (pending.length) {
|
|
1351
|
+
var target = pending.pop();
|
|
1352
|
+
var keys = Object.keys(target);
|
|
1353
|
+
for (var i = 0; i < keys.length; i++) {
|
|
1354
|
+
normalizeEntry(target, keys[i]);
|
|
1355
|
+
}
|
|
1356
|
+
}
|
|
1357
|
+
return obj;
|
|
1358
|
+
}
|
|
1359
|
+
|
|
1257
1360
|
function formDataToJSON(formData) {
|
|
1258
1361
|
function buildPath(path, value, target, index) {
|
|
1259
1362
|
var name = path[index++];
|
|
1260
1363
|
|
|
1261
1364
|
if (name === '__proto__') return true;
|
|
1262
1365
|
|
|
1263
|
-
var isNumericKey =
|
|
1366
|
+
var isNumericKey = isFinite(+name);
|
|
1264
1367
|
var isLast = index >= path.length;
|
|
1265
1368
|
name = !name && utils.isArray(target) ? target.length : name;
|
|
1266
1369
|
|
|
@@ -1274,7 +1377,7 @@ function formDataToJSON(formData) {
|
|
|
1274
1377
|
return !isNumericKey;
|
|
1275
1378
|
}
|
|
1276
1379
|
|
|
1277
|
-
if (!target
|
|
1380
|
+
if (!utils.hasOwnProperty(target, name) || !utils.isObject(target[name])) {
|
|
1278
1381
|
target[name] = [];
|
|
1279
1382
|
}
|
|
1280
1383
|
|
|
@@ -1297,7 +1400,7 @@ function formDataToJSON(formData) {
|
|
|
1297
1400
|
buildPath(path, value, obj, 0);
|
|
1298
1401
|
});
|
|
1299
1402
|
|
|
1300
|
-
return obj;
|
|
1403
|
+
return normalizeArrays(obj);
|
|
1301
1404
|
}
|
|
1302
1405
|
|
|
1303
1406
|
return null;
|
|
@@ -2191,6 +2294,102 @@ var dispatchRequest = function dispatchRequest(config) {
|
|
|
2191
2294
|
});
|
|
2192
2295
|
};
|
|
2193
2296
|
|
|
2297
|
+
// Match numeric array reads without scanning unoccupied slots or metadata.
|
|
2298
|
+
function arrayIndexes(array) {
|
|
2299
|
+
var length = array.length;
|
|
2300
|
+
var indexes = Object.create(null);
|
|
2301
|
+
var keys = [];
|
|
2302
|
+
var source = array;
|
|
2303
|
+
var fast = array;
|
|
2304
|
+
while (source) {
|
|
2305
|
+
var names = Object.getOwnPropertyNames(source);
|
|
2306
|
+
for (var i = 0; i < names.length; i++) {
|
|
2307
|
+
var key = names[i];
|
|
2308
|
+
var index = +key;
|
|
2309
|
+
if (index >= 0 && index < length && Math.floor(index) === index &&
|
|
2310
|
+
String(index) === key && !indexes[key]) {
|
|
2311
|
+
indexes[key] = true;
|
|
2312
|
+
keys.push(key);
|
|
2313
|
+
}
|
|
2314
|
+
}
|
|
2315
|
+
source = Object.getPrototypeOf(source);
|
|
2316
|
+
// Detect unusual cyclic prototype chains with constant memory.
|
|
2317
|
+
fast = fast && Object.getPrototypeOf(fast);
|
|
2318
|
+
fast = fast && Object.getPrototypeOf(fast);
|
|
2319
|
+
if (source && source === fast) {
|
|
2320
|
+
throw new AxiosError_1('Circular prototype chain in params', AxiosError_1.ERR_BAD_OPTION_VALUE);
|
|
2321
|
+
}
|
|
2322
|
+
}
|
|
2323
|
+
return keys.sort(function(a, b) { return a - b; });
|
|
2324
|
+
}
|
|
2325
|
+
|
|
2326
|
+
var assertParamsDepth = function assertParamsDepth(params) {
|
|
2327
|
+
if (!utils.isObject(params)) return;
|
|
2328
|
+
var pending = [{ value: params, depth: 0, complete: false }];
|
|
2329
|
+
var ancestors = [];
|
|
2330
|
+
var visited = null;
|
|
2331
|
+
if (typeof WeakMap === 'function') {
|
|
2332
|
+
visited = new WeakMap();
|
|
2333
|
+
} else if (typeof Map === 'function') {
|
|
2334
|
+
visited = new Map();
|
|
2335
|
+
}
|
|
2336
|
+
// Older runtimes can only compare immutable object identities by scanning.
|
|
2337
|
+
// Keep that scan bounded; recently completed subgraphs avoid repeated work,
|
|
2338
|
+
// while evicted shared subgraphs may be visited again.
|
|
2339
|
+
var cacheSize = 128;
|
|
2340
|
+
var visitedValues = [];
|
|
2341
|
+
var visitedDepths = [];
|
|
2342
|
+
var nextCacheIndex = 0;
|
|
2343
|
+
while (pending.length) {
|
|
2344
|
+
var entry = pending.pop();
|
|
2345
|
+
var value = entry.value;
|
|
2346
|
+
var index;
|
|
2347
|
+
if (entry.complete) {
|
|
2348
|
+
ancestors.pop();
|
|
2349
|
+
if (visited) {
|
|
2350
|
+
visited.set(value, entry.depth);
|
|
2351
|
+
} else {
|
|
2352
|
+
index = visitedValues.indexOf(value);
|
|
2353
|
+
if (index === -1) {
|
|
2354
|
+
index = nextCacheIndex;
|
|
2355
|
+
nextCacheIndex = (nextCacheIndex + 1) % cacheSize;
|
|
2356
|
+
}
|
|
2357
|
+
visitedValues[index] = value;
|
|
2358
|
+
visitedDepths[index] = entry.depth;
|
|
2359
|
+
}
|
|
2360
|
+
continue;
|
|
2361
|
+
}
|
|
2362
|
+
// The serializer enumerates any object at its root, then recursively
|
|
2363
|
+
// visits only plain objects and arrays below that root.
|
|
2364
|
+
if (entry.depth === 0 ? !utils.isObject(value) :
|
|
2365
|
+
!utils.isPlainObject(value) && !utils.isArray(value)) {
|
|
2366
|
+
continue;
|
|
2367
|
+
}
|
|
2368
|
+
if (entry.depth > 100) {
|
|
2369
|
+
throw new AxiosError_1('params exceed the maximum depth of 100', AxiosError_1.ERR_BAD_OPTION_VALUE);
|
|
2370
|
+
}
|
|
2371
|
+
// The depth cap bounds this ancestry scan independently of params width.
|
|
2372
|
+
if (ancestors.indexOf(value) !== -1) {
|
|
2373
|
+
throw new AxiosError_1('Circular reference detected in params', AxiosError_1.ERR_BAD_OPTION_VALUE);
|
|
2374
|
+
}
|
|
2375
|
+
if (visited) {
|
|
2376
|
+
if (visited.has(value) && visited.get(value) >= entry.depth) continue;
|
|
2377
|
+
} else {
|
|
2378
|
+
index = visitedValues.indexOf(value);
|
|
2379
|
+
if (index !== -1 && visitedDepths[index] >= entry.depth) continue;
|
|
2380
|
+
}
|
|
2381
|
+
ancestors.push(value);
|
|
2382
|
+
pending.push({ value: value, depth: entry.depth, complete: true });
|
|
2383
|
+
var keys = utils.isArray(value) ? arrayIndexes(value) : Object.keys(value);
|
|
2384
|
+
for (var i = 0; i < keys.length; i++) {
|
|
2385
|
+
var key = keys[i];
|
|
2386
|
+
if (key !== '__proto__' && key !== 'constructor' && key !== 'prototype') {
|
|
2387
|
+
pending.push({ value: value[key], depth: entry.depth + 1, complete: false });
|
|
2388
|
+
}
|
|
2389
|
+
}
|
|
2390
|
+
}
|
|
2391
|
+
};
|
|
2392
|
+
|
|
2194
2393
|
/**
|
|
2195
2394
|
* Config-specific merge-function which creates a new config-object
|
|
2196
2395
|
* by merging two configuration objects together.
|
|
@@ -2202,6 +2401,8 @@ var dispatchRequest = function dispatchRequest(config) {
|
|
|
2202
2401
|
var mergeConfig = function mergeConfig(config1, config2) {
|
|
2203
2402
|
// eslint-disable-next-line no-param-reassign
|
|
2204
2403
|
config2 = config2 || {};
|
|
2404
|
+
assertParamsDepth(utils.hasOwnProperty(config1, 'params') ? config1.params : undefined);
|
|
2405
|
+
assertParamsDepth(utils.hasOwnProperty(config2, 'params') ? config2.params : undefined);
|
|
2205
2406
|
// Use a null-prototype object so a polluted Object.prototype cannot leak
|
|
2206
2407
|
// values (e.g. transport, adapter) into the returned config via inheritance.
|
|
2207
2408
|
var config = Object.create(null);
|
|
@@ -2313,7 +2514,7 @@ var mergeConfig = function mergeConfig(config1, config2) {
|
|
|
2313
2514
|
};
|
|
2314
2515
|
|
|
2315
2516
|
var data = {
|
|
2316
|
-
"version": "0.
|
|
2517
|
+
"version": "0.35.0"
|
|
2317
2518
|
};
|
|
2318
2519
|
|
|
2319
2520
|
var VERSION = data.version;
|
|
@@ -2481,7 +2682,11 @@ Axios.prototype.request = function request(configOrUrl, config) {
|
|
|
2481
2682
|
config = configOrUrl || {};
|
|
2482
2683
|
}
|
|
2483
2684
|
|
|
2484
|
-
|
|
2685
|
+
try {
|
|
2686
|
+
config = mergeConfig(this.defaults, config);
|
|
2687
|
+
} catch (error) {
|
|
2688
|
+
return Promise.reject(error);
|
|
2689
|
+
}
|
|
2485
2690
|
var caller = config.captureCallerStack === true ? captureCallerStack(request) : null;
|
|
2486
2691
|
|
|
2487
2692
|
// Set config.method. The merged config is null-prototype, but instance
|
|
@@ -2607,11 +2812,16 @@ utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData
|
|
|
2607
2812
|
Axios.prototype[method] = function(url, config) {
|
|
2608
2813
|
var requestConfig = config || {};
|
|
2609
2814
|
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2815
|
+
try {
|
|
2816
|
+
requestConfig = mergeConfig(requestConfig, {
|
|
2817
|
+
method: method,
|
|
2818
|
+
url: url,
|
|
2819
|
+
data: utils.hasOwnProperty(requestConfig, 'data') ? requestConfig.data : undefined
|
|
2820
|
+
});
|
|
2821
|
+
} catch (error) {
|
|
2822
|
+
return Promise.reject(error);
|
|
2823
|
+
}
|
|
2824
|
+
return this.request(requestConfig);
|
|
2615
2825
|
};
|
|
2616
2826
|
});
|
|
2617
2827
|
|
|
@@ -2620,14 +2830,20 @@ utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
|
|
2620
2830
|
|
|
2621
2831
|
function generateHTTPMethod(isForm) {
|
|
2622
2832
|
return function httpMethod(url, data, config) {
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2833
|
+
var requestConfig;
|
|
2834
|
+
try {
|
|
2835
|
+
requestConfig = mergeConfig(config || {}, {
|
|
2836
|
+
method: method,
|
|
2837
|
+
headers: isForm ? {
|
|
2838
|
+
'Content-Type': 'multipart/form-data'
|
|
2839
|
+
} : {},
|
|
2840
|
+
url: url,
|
|
2841
|
+
data: data
|
|
2842
|
+
});
|
|
2843
|
+
} catch (error) {
|
|
2844
|
+
return Promise.reject(error);
|
|
2845
|
+
}
|
|
2846
|
+
return this.request(requestConfig);
|
|
2631
2847
|
};
|
|
2632
2848
|
}
|
|
2633
2849
|
|