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/axios.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// axios v0.
|
|
1
|
+
// axios v0.35.0 Copyright (c) 2026 Matt Zabriskie
|
|
2
2
|
(function (global, factory) {
|
|
3
3
|
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
4
4
|
typeof define === 'function' && define.amd ? define(factory) :
|
|
@@ -517,10 +517,75 @@
|
|
|
517
517
|
if (!thing) return null;
|
|
518
518
|
if (isArray(thing)) return thing;
|
|
519
519
|
var i = thing.length;
|
|
520
|
-
if (
|
|
520
|
+
if (typeof i !== 'number' || i < 0 || i > 0xffffffff || Math.floor(i) !== i) return null;
|
|
521
|
+
|
|
522
|
+
// Legacy FileList hosts expose indexed reads without reflecting their keys.
|
|
523
|
+
if (isFileList(thing)) {
|
|
524
|
+
var files = [];
|
|
525
|
+
while (i-- > 0) {
|
|
526
|
+
var file = thing[i];
|
|
527
|
+
if (file === null || isUndefined(file)) return null;
|
|
528
|
+
defineOwnProperty(files, i, file);
|
|
529
|
+
}
|
|
530
|
+
return files;
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
// Count actual indexes, including hidden collection properties, before
|
|
534
|
+
// allocating from the declared length. Box primitives for ES5 object APIs.
|
|
535
|
+
var source = Object(thing);
|
|
536
|
+
var indexes = Object.create(null);
|
|
537
|
+
var count = 0;
|
|
538
|
+
var seen = [];
|
|
539
|
+
var owns = Object.prototype.hasOwnProperty;
|
|
540
|
+
|
|
541
|
+
while (source && count < i) {
|
|
542
|
+
if (seen.indexOf(source) !== -1) return null;
|
|
543
|
+
defineOwnProperty(seen, seen.length, source);
|
|
544
|
+
|
|
545
|
+
if (source === Object.prototype) break;
|
|
546
|
+
|
|
547
|
+
var prototype = Object.getPrototypeOf(source);
|
|
548
|
+
if (prototype === null) {
|
|
549
|
+
var constructorDescriptor = Object.getOwnPropertyDescriptor(source, 'constructor');
|
|
550
|
+
var constructorValue = constructorDescriptor && owns.call(constructorDescriptor, 'value') &&
|
|
551
|
+
constructorDescriptor.value;
|
|
552
|
+
var constructorPrototype = typeof constructorValue === 'function' &&
|
|
553
|
+
Object.getOwnPropertyDescriptor(constructorValue, 'prototype');
|
|
554
|
+
|
|
555
|
+
// Recognize another realm's Object.prototype without excluding
|
|
556
|
+
// application-defined null-prototype parents or invoking accessors.
|
|
557
|
+
if (
|
|
558
|
+
constructorPrototype && owns.call(constructorPrototype, 'value') &&
|
|
559
|
+
constructorPrototype.value === source &&
|
|
560
|
+
Function.prototype.toString.call(constructorValue) === Function.prototype.toString.call(Object)
|
|
561
|
+
) {
|
|
562
|
+
break;
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
var keys = Object.getOwnPropertyNames(source);
|
|
567
|
+
for (var j = 0; j < keys.length; j++) {
|
|
568
|
+
var key = keys[j];
|
|
569
|
+
var index = +key;
|
|
570
|
+
if (
|
|
571
|
+
index >= 0 &&
|
|
572
|
+
index < i &&
|
|
573
|
+
Math.floor(index) === index &&
|
|
574
|
+
String(index) === key &&
|
|
575
|
+
owns.call(source, key) &&
|
|
576
|
+
!indexes[key]
|
|
577
|
+
) {
|
|
578
|
+
indexes[key] = true;
|
|
579
|
+
count++;
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
source = prototype;
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
if (count !== i) return null;
|
|
521
586
|
var arr = new Array(i);
|
|
522
587
|
while (i-- > 0) {
|
|
523
|
-
arr
|
|
588
|
+
defineOwnProperty(arr, i, thing[i]);
|
|
524
589
|
}
|
|
525
590
|
return arr;
|
|
526
591
|
}
|
|
@@ -590,6 +655,7 @@
|
|
|
590
655
|
trim: trim,
|
|
591
656
|
stripBOM: stripBOM,
|
|
592
657
|
inherits: inherits,
|
|
658
|
+
defineOwnProperty: defineOwnProperty,
|
|
593
659
|
toFlatObject: toFlatObject,
|
|
594
660
|
kindOf: kindOf,
|
|
595
661
|
kindOfTest: kindOfTest,
|
|
@@ -911,7 +977,7 @@
|
|
|
911
977
|
return;
|
|
912
978
|
}
|
|
913
979
|
|
|
914
|
-
stack.
|
|
980
|
+
utils.defineOwnProperty(stack, stack.length, value);
|
|
915
981
|
|
|
916
982
|
utils.forEach(value, function each(el) {
|
|
917
983
|
assertValueDepth(el, depth + 1);
|
|
@@ -940,8 +1006,8 @@
|
|
|
940
1006
|
value = JSON.stringify(value);
|
|
941
1007
|
} else if (
|
|
942
1008
|
(utils.isArray(value) && isFlatArray(value)) ||
|
|
943
|
-
(utils.isFileList(value) || utils.endsWith(key, '[]') && (arr = utils.toArray(value))
|
|
944
|
-
|
|
1009
|
+
((utils.isFileList(value) || utils.endsWith(key, '[]')) && (arr = utils.toArray(value)))
|
|
1010
|
+
) {
|
|
945
1011
|
// eslint-disable-next-line no-param-reassign
|
|
946
1012
|
key = removeBrackets(key);
|
|
947
1013
|
|
|
@@ -988,7 +1054,7 @@
|
|
|
988
1054
|
throw Error('Circular reference detected in ' + path.join('.'));
|
|
989
1055
|
}
|
|
990
1056
|
|
|
991
|
-
stack.
|
|
1057
|
+
utils.defineOwnProperty(stack, stack.length, value);
|
|
992
1058
|
|
|
993
1059
|
utils.forEach(value, function each(el, key) {
|
|
994
1060
|
var result = !(utils.isUndefined(el) || el === null) && visitor.call(
|
|
@@ -1260,13 +1326,50 @@
|
|
|
1260
1326
|
return obj;
|
|
1261
1327
|
}
|
|
1262
1328
|
|
|
1329
|
+
function normalizeArray(value) {
|
|
1330
|
+
if (!utils.isArray(value)) return value;
|
|
1331
|
+
|
|
1332
|
+
var keys = Object.keys(value);
|
|
1333
|
+
if (keys.length !== value.length) return arrayToObject(value);
|
|
1334
|
+
|
|
1335
|
+
for (var i = 0; i < keys.length; i++) {
|
|
1336
|
+
var index = +keys[i];
|
|
1337
|
+
if (
|
|
1338
|
+
index < 0 || index >= value.length ||
|
|
1339
|
+
Math.floor(index) !== index || String(index) !== keys[i]
|
|
1340
|
+
) {
|
|
1341
|
+
return arrayToObject(value);
|
|
1342
|
+
}
|
|
1343
|
+
}
|
|
1344
|
+
|
|
1345
|
+
return value;
|
|
1346
|
+
}
|
|
1347
|
+
|
|
1348
|
+
function normalizeArrays(obj) {
|
|
1349
|
+
var pending = [obj];
|
|
1350
|
+
function normalizeEntry(target, key) {
|
|
1351
|
+
var value = target[key] = normalizeArray(target[key]);
|
|
1352
|
+
if (utils.isArray(value) || utils.isPlainObject(value)) {
|
|
1353
|
+
pending.push(value);
|
|
1354
|
+
}
|
|
1355
|
+
}
|
|
1356
|
+
while (pending.length) {
|
|
1357
|
+
var target = pending.pop();
|
|
1358
|
+
var keys = Object.keys(target);
|
|
1359
|
+
for (var i = 0; i < keys.length; i++) {
|
|
1360
|
+
normalizeEntry(target, keys[i]);
|
|
1361
|
+
}
|
|
1362
|
+
}
|
|
1363
|
+
return obj;
|
|
1364
|
+
}
|
|
1365
|
+
|
|
1263
1366
|
function formDataToJSON(formData) {
|
|
1264
1367
|
function buildPath(path, value, target, index) {
|
|
1265
1368
|
var name = path[index++];
|
|
1266
1369
|
|
|
1267
1370
|
if (name === '__proto__') return true;
|
|
1268
1371
|
|
|
1269
|
-
var isNumericKey =
|
|
1372
|
+
var isNumericKey = isFinite(+name);
|
|
1270
1373
|
var isLast = index >= path.length;
|
|
1271
1374
|
name = !name && utils.isArray(target) ? target.length : name;
|
|
1272
1375
|
|
|
@@ -1280,7 +1383,7 @@
|
|
|
1280
1383
|
return !isNumericKey;
|
|
1281
1384
|
}
|
|
1282
1385
|
|
|
1283
|
-
if (!target
|
|
1386
|
+
if (!utils.hasOwnProperty(target, name) || !utils.isObject(target[name])) {
|
|
1284
1387
|
target[name] = [];
|
|
1285
1388
|
}
|
|
1286
1389
|
|
|
@@ -1303,7 +1406,7 @@
|
|
|
1303
1406
|
buildPath(path, value, obj, 0);
|
|
1304
1407
|
});
|
|
1305
1408
|
|
|
1306
|
-
return obj;
|
|
1409
|
+
return normalizeArrays(obj);
|
|
1307
1410
|
}
|
|
1308
1411
|
|
|
1309
1412
|
return null;
|
|
@@ -2197,6 +2300,102 @@
|
|
|
2197
2300
|
});
|
|
2198
2301
|
};
|
|
2199
2302
|
|
|
2303
|
+
// Match numeric array reads without scanning unoccupied slots or metadata.
|
|
2304
|
+
function arrayIndexes(array) {
|
|
2305
|
+
var length = array.length;
|
|
2306
|
+
var indexes = Object.create(null);
|
|
2307
|
+
var keys = [];
|
|
2308
|
+
var source = array;
|
|
2309
|
+
var fast = array;
|
|
2310
|
+
while (source) {
|
|
2311
|
+
var names = Object.getOwnPropertyNames(source);
|
|
2312
|
+
for (var i = 0; i < names.length; i++) {
|
|
2313
|
+
var key = names[i];
|
|
2314
|
+
var index = +key;
|
|
2315
|
+
if (index >= 0 && index < length && Math.floor(index) === index &&
|
|
2316
|
+
String(index) === key && !indexes[key]) {
|
|
2317
|
+
indexes[key] = true;
|
|
2318
|
+
keys.push(key);
|
|
2319
|
+
}
|
|
2320
|
+
}
|
|
2321
|
+
source = Object.getPrototypeOf(source);
|
|
2322
|
+
// Detect unusual cyclic prototype chains with constant memory.
|
|
2323
|
+
fast = fast && Object.getPrototypeOf(fast);
|
|
2324
|
+
fast = fast && Object.getPrototypeOf(fast);
|
|
2325
|
+
if (source && source === fast) {
|
|
2326
|
+
throw new AxiosError_1('Circular prototype chain in params', AxiosError_1.ERR_BAD_OPTION_VALUE);
|
|
2327
|
+
}
|
|
2328
|
+
}
|
|
2329
|
+
return keys.sort(function(a, b) { return a - b; });
|
|
2330
|
+
}
|
|
2331
|
+
|
|
2332
|
+
var assertParamsDepth = function assertParamsDepth(params) {
|
|
2333
|
+
if (!utils.isObject(params)) return;
|
|
2334
|
+
var pending = [{ value: params, depth: 0, complete: false }];
|
|
2335
|
+
var ancestors = [];
|
|
2336
|
+
var visited = null;
|
|
2337
|
+
if (typeof WeakMap === 'function') {
|
|
2338
|
+
visited = new WeakMap();
|
|
2339
|
+
} else if (typeof Map === 'function') {
|
|
2340
|
+
visited = new Map();
|
|
2341
|
+
}
|
|
2342
|
+
// Older runtimes can only compare immutable object identities by scanning.
|
|
2343
|
+
// Keep that scan bounded; recently completed subgraphs avoid repeated work,
|
|
2344
|
+
// while evicted shared subgraphs may be visited again.
|
|
2345
|
+
var cacheSize = 128;
|
|
2346
|
+
var visitedValues = [];
|
|
2347
|
+
var visitedDepths = [];
|
|
2348
|
+
var nextCacheIndex = 0;
|
|
2349
|
+
while (pending.length) {
|
|
2350
|
+
var entry = pending.pop();
|
|
2351
|
+
var value = entry.value;
|
|
2352
|
+
var index;
|
|
2353
|
+
if (entry.complete) {
|
|
2354
|
+
ancestors.pop();
|
|
2355
|
+
if (visited) {
|
|
2356
|
+
visited.set(value, entry.depth);
|
|
2357
|
+
} else {
|
|
2358
|
+
index = visitedValues.indexOf(value);
|
|
2359
|
+
if (index === -1) {
|
|
2360
|
+
index = nextCacheIndex;
|
|
2361
|
+
nextCacheIndex = (nextCacheIndex + 1) % cacheSize;
|
|
2362
|
+
}
|
|
2363
|
+
visitedValues[index] = value;
|
|
2364
|
+
visitedDepths[index] = entry.depth;
|
|
2365
|
+
}
|
|
2366
|
+
continue;
|
|
2367
|
+
}
|
|
2368
|
+
// The serializer enumerates any object at its root, then recursively
|
|
2369
|
+
// visits only plain objects and arrays below that root.
|
|
2370
|
+
if (entry.depth === 0 ? !utils.isObject(value) :
|
|
2371
|
+
!utils.isPlainObject(value) && !utils.isArray(value)) {
|
|
2372
|
+
continue;
|
|
2373
|
+
}
|
|
2374
|
+
if (entry.depth > 100) {
|
|
2375
|
+
throw new AxiosError_1('params exceed the maximum depth of 100', AxiosError_1.ERR_BAD_OPTION_VALUE);
|
|
2376
|
+
}
|
|
2377
|
+
// The depth cap bounds this ancestry scan independently of params width.
|
|
2378
|
+
if (ancestors.indexOf(value) !== -1) {
|
|
2379
|
+
throw new AxiosError_1('Circular reference detected in params', AxiosError_1.ERR_BAD_OPTION_VALUE);
|
|
2380
|
+
}
|
|
2381
|
+
if (visited) {
|
|
2382
|
+
if (visited.has(value) && visited.get(value) >= entry.depth) continue;
|
|
2383
|
+
} else {
|
|
2384
|
+
index = visitedValues.indexOf(value);
|
|
2385
|
+
if (index !== -1 && visitedDepths[index] >= entry.depth) continue;
|
|
2386
|
+
}
|
|
2387
|
+
ancestors.push(value);
|
|
2388
|
+
pending.push({ value: value, depth: entry.depth, complete: true });
|
|
2389
|
+
var keys = utils.isArray(value) ? arrayIndexes(value) : Object.keys(value);
|
|
2390
|
+
for (var i = 0; i < keys.length; i++) {
|
|
2391
|
+
var key = keys[i];
|
|
2392
|
+
if (key !== '__proto__' && key !== 'constructor' && key !== 'prototype') {
|
|
2393
|
+
pending.push({ value: value[key], depth: entry.depth + 1, complete: false });
|
|
2394
|
+
}
|
|
2395
|
+
}
|
|
2396
|
+
}
|
|
2397
|
+
};
|
|
2398
|
+
|
|
2200
2399
|
/**
|
|
2201
2400
|
* Config-specific merge-function which creates a new config-object
|
|
2202
2401
|
* by merging two configuration objects together.
|
|
@@ -2208,6 +2407,8 @@
|
|
|
2208
2407
|
var mergeConfig = function mergeConfig(config1, config2) {
|
|
2209
2408
|
// eslint-disable-next-line no-param-reassign
|
|
2210
2409
|
config2 = config2 || {};
|
|
2410
|
+
assertParamsDepth(utils.hasOwnProperty(config1, 'params') ? config1.params : undefined);
|
|
2411
|
+
assertParamsDepth(utils.hasOwnProperty(config2, 'params') ? config2.params : undefined);
|
|
2211
2412
|
// Use a null-prototype object so a polluted Object.prototype cannot leak
|
|
2212
2413
|
// values (e.g. transport, adapter) into the returned config via inheritance.
|
|
2213
2414
|
var config = Object.create(null);
|
|
@@ -2319,7 +2520,7 @@
|
|
|
2319
2520
|
};
|
|
2320
2521
|
|
|
2321
2522
|
var data = {
|
|
2322
|
-
"version": "0.
|
|
2523
|
+
"version": "0.35.0"
|
|
2323
2524
|
};
|
|
2324
2525
|
|
|
2325
2526
|
var VERSION = data.version;
|
|
@@ -2487,7 +2688,11 @@
|
|
|
2487
2688
|
config = configOrUrl || {};
|
|
2488
2689
|
}
|
|
2489
2690
|
|
|
2490
|
-
|
|
2691
|
+
try {
|
|
2692
|
+
config = mergeConfig(this.defaults, config);
|
|
2693
|
+
} catch (error) {
|
|
2694
|
+
return Promise.reject(error);
|
|
2695
|
+
}
|
|
2491
2696
|
var caller = config.captureCallerStack === true ? captureCallerStack(request) : null;
|
|
2492
2697
|
|
|
2493
2698
|
// Set config.method. The merged config is null-prototype, but instance
|
|
@@ -2613,11 +2818,16 @@
|
|
|
2613
2818
|
Axios.prototype[method] = function(url, config) {
|
|
2614
2819
|
var requestConfig = config || {};
|
|
2615
2820
|
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2821
|
+
try {
|
|
2822
|
+
requestConfig = mergeConfig(requestConfig, {
|
|
2823
|
+
method: method,
|
|
2824
|
+
url: url,
|
|
2825
|
+
data: utils.hasOwnProperty(requestConfig, 'data') ? requestConfig.data : undefined
|
|
2826
|
+
});
|
|
2827
|
+
} catch (error) {
|
|
2828
|
+
return Promise.reject(error);
|
|
2829
|
+
}
|
|
2830
|
+
return this.request(requestConfig);
|
|
2621
2831
|
};
|
|
2622
2832
|
});
|
|
2623
2833
|
|
|
@@ -2626,14 +2836,20 @@
|
|
|
2626
2836
|
|
|
2627
2837
|
function generateHTTPMethod(isForm) {
|
|
2628
2838
|
return function httpMethod(url, data, config) {
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2839
|
+
var requestConfig;
|
|
2840
|
+
try {
|
|
2841
|
+
requestConfig = mergeConfig(config || {}, {
|
|
2842
|
+
method: method,
|
|
2843
|
+
headers: isForm ? {
|
|
2844
|
+
'Content-Type': 'multipart/form-data'
|
|
2845
|
+
} : {},
|
|
2846
|
+
url: url,
|
|
2847
|
+
data: data
|
|
2848
|
+
});
|
|
2849
|
+
} catch (error) {
|
|
2850
|
+
return Promise.reject(error);
|
|
2851
|
+
}
|
|
2852
|
+
return this.request(requestConfig);
|
|
2637
2853
|
};
|
|
2638
2854
|
}
|
|
2639
2855
|
|