axios 1.16.1 → 1.18.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 CHANGED
@@ -1,4 +1,4 @@
1
- /*! Axios v1.16.1 Copyright (c) 2026 Matt Zabriskie and contributors */
1
+ /*! Axios v1.18.0 Copyright (c) 2026 Matt Zabriskie and contributors */
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) :
@@ -463,55 +463,42 @@
463
463
  };
464
464
  }
465
465
  function AsyncGenerator(e) {
466
- var r, t;
467
- function resume(r, t) {
466
+ var t, n;
467
+ function resume(t, n) {
468
468
  try {
469
- var n = e[r](t),
470
- o = n.value,
469
+ var r = e[t](n),
470
+ o = r.value,
471
471
  u = o instanceof _OverloadYield;
472
- Promise.resolve(u ? o.v : o).then(function (t) {
472
+ Promise.resolve(u ? o.v : o).then(function (n) {
473
473
  if (u) {
474
- var i = "return" === r ? "return" : "next";
475
- if (!o.k || t.done) return resume(i, t);
476
- t = e[i](t).value;
474
+ var i = "return" === t && o.k ? t : "next";
475
+ if (!o.k || n.done) return resume(i, n);
476
+ n = e[i](n).value;
477
477
  }
478
- settle(n.done ? "return" : "normal", t);
478
+ settle(!!r.done, n);
479
479
  }, function (e) {
480
480
  resume("throw", e);
481
481
  });
482
482
  } catch (e) {
483
- settle("throw", e);
483
+ settle(2, e);
484
484
  }
485
485
  }
486
- function settle(e, n) {
487
- switch (e) {
488
- case "return":
489
- r.resolve({
490
- value: n,
491
- done: true
492
- });
493
- break;
494
- case "throw":
495
- r.reject(n);
496
- break;
497
- default:
498
- r.resolve({
499
- value: n,
500
- done: false
501
- });
502
- }
503
- (r = r.next) ? resume(r.key, r.arg) : t = null;
486
+ function settle(e, r) {
487
+ 2 === e ? t.reject(r) : t.resolve({
488
+ value: r,
489
+ done: e
490
+ }), (t = t.next) ? resume(t.key, t.arg) : n = null;
504
491
  }
505
- this._invoke = function (e, n) {
492
+ this._invoke = function (e, r) {
506
493
  return new Promise(function (o, u) {
507
494
  var i = {
508
495
  key: e,
509
- arg: n,
496
+ arg: r,
510
497
  resolve: o,
511
498
  reject: u,
512
499
  next: null
513
500
  };
514
- t ? t = t.next = i : (r = t = i, resume(e, n));
501
+ n ? n = n.next = i : (t = n = i, resume(e, r));
515
502
  });
516
503
  }, "function" != typeof e.return && (this.return = void 0);
517
504
  }
@@ -566,6 +553,57 @@
566
553
  var getPrototypeOf = Object.getPrototypeOf;
567
554
  var iterator = Symbol.iterator,
568
555
  toStringTag = Symbol.toStringTag;
556
+
557
+ /* Creating a function that will check if an object has a property. */
558
+ var hasOwnProperty = function (_ref) {
559
+ var hasOwnProperty = _ref.hasOwnProperty;
560
+ return function (obj, prop) {
561
+ return hasOwnProperty.call(obj, prop);
562
+ };
563
+ }(Object.prototype);
564
+
565
+ /**
566
+ * Walk the prototype chain (excluding the shared Object.prototype) looking for
567
+ * an own `prop`. This distinguishes genuine own/inherited members — including
568
+ * class accessors and template prototypes — from members injected via
569
+ * Object.prototype pollution (e.g. `Object.prototype.username = '...'`), which
570
+ * live on Object.prototype itself and are therefore never matched.
571
+ *
572
+ * @param {*} thing The value whose chain to inspect
573
+ * @param {string|symbol} prop The property key to look for
574
+ *
575
+ * @returns {boolean} True when `prop` is owned below Object.prototype
576
+ */
577
+ var hasOwnInPrototypeChain = function hasOwnInPrototypeChain(thing, prop) {
578
+ var obj = thing;
579
+ var seen = [];
580
+ while (obj != null && obj !== Object.prototype) {
581
+ if (seen.indexOf(obj) !== -1) {
582
+ return false;
583
+ }
584
+ seen.push(obj);
585
+ if (hasOwnProperty(obj, prop)) {
586
+ return true;
587
+ }
588
+ obj = getPrototypeOf(obj);
589
+ }
590
+ return false;
591
+ };
592
+
593
+ /**
594
+ * Read `obj[prop]` only when it is safe from Object.prototype pollution. Own
595
+ * properties and members inherited from a non-Object.prototype source (a class
596
+ * instance or template object) are honored; a value reachable only through a
597
+ * polluted Object.prototype is ignored and `undefined` is returned.
598
+ *
599
+ * @param {*} obj The source object
600
+ * @param {string|symbol} prop The property key to read
601
+ *
602
+ * @returns {*} The resolved value, or undefined when unsafe/absent
603
+ */
604
+ var getSafeProp = function getSafeProp(obj, prop) {
605
+ return obj != null && hasOwnInPrototypeChain(obj, prop) ? obj[prop] : undefined;
606
+ };
569
607
  var kindOf = function (cache) {
570
608
  return function (thing) {
571
609
  var str = toString.call(thing);
@@ -694,11 +732,15 @@
694
732
  * @returns {boolean} True if value is a plain Object, otherwise false
695
733
  */
696
734
  var isPlainObject = function isPlainObject(val) {
697
- if (kindOf(val) !== 'object') {
735
+ if (!isObject(val)) {
698
736
  return false;
699
737
  }
700
738
  var prototype = getPrototypeOf(val);
701
- return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(toStringTag in val) && !(iterator in val);
739
+ return (prototype === null || prototype === Object.prototype || getPrototypeOf(prototype) === null) &&
740
+ // Treat any genuine (non-Object.prototype-polluted) Symbol.toStringTag or
741
+ // Symbol.iterator as evidence the value is a tagged/iterable type rather
742
+ // than a plain object, while ignoring keys injected onto Object.prototype.
743
+ !hasOwnInPrototypeChain(val, toStringTag) && !hasOwnInPrototypeChain(val, iterator);
702
744
  };
703
745
 
704
746
  /**
@@ -866,9 +908,9 @@
866
908
  * @returns {any}
867
909
  */
868
910
  function forEach(obj, fn) {
869
- var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
870
- _ref$allOwnKeys = _ref.allOwnKeys,
871
- allOwnKeys = _ref$allOwnKeys === void 0 ? false : _ref$allOwnKeys;
911
+ var _ref2 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
912
+ _ref2$allOwnKeys = _ref2.allOwnKeys,
913
+ allOwnKeys = _ref2$allOwnKeys === void 0 ? false : _ref2$allOwnKeys;
872
914
  // Don't bother if no value provided
873
915
  if (obj === null || typeof obj === 'undefined') {
874
916
  return;
@@ -955,16 +997,19 @@
955
997
  * @returns {Object} Result of all merge properties
956
998
  */
957
999
  function merge() {
958
- var _ref2 = isContextDefined(this) && this || {},
959
- caseless = _ref2.caseless,
960
- skipUndefined = _ref2.skipUndefined;
1000
+ var _ref3 = isContextDefined(this) && this || {},
1001
+ caseless = _ref3.caseless,
1002
+ skipUndefined = _ref3.skipUndefined;
961
1003
  var result = {};
962
1004
  var assignValue = function assignValue(val, key) {
963
1005
  // Skip dangerous property names to prevent prototype pollution
964
1006
  if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
965
1007
  return;
966
1008
  }
967
- var targetKey = caseless && findKey(result, key) || key;
1009
+
1010
+ // findKey lowercases the key, so caseless lookup only applies to strings —
1011
+ // symbol keys are identity-matched.
1012
+ var targetKey = caseless && typeof key === 'string' && findKey(result, key) || key;
968
1013
  // Read via own-prop only — a bare `result[targetKey]` walks the prototype
969
1014
  // chain, so a polluted Object.prototype value could surface here and get
970
1015
  // copied into the merged result.
@@ -979,11 +1024,22 @@
979
1024
  result[targetKey] = val;
980
1025
  }
981
1026
  };
982
- for (var _len = arguments.length, objs = new Array(_len), _key2 = 0; _key2 < _len; _key2++) {
983
- objs[_key2] = arguments[_key2];
984
- }
985
- for (var i = 0, l = objs.length; i < l; i++) {
986
- objs[i] && forEach(objs[i], assignValue);
1027
+ for (var i = 0, l = arguments.length; i < l; i++) {
1028
+ var source = i < 0 || arguments.length <= i ? undefined : arguments[i];
1029
+ if (!source || isBuffer(source)) {
1030
+ continue;
1031
+ }
1032
+ forEach(source, assignValue);
1033
+ if (_typeof(source) !== 'object' || isArray(source)) {
1034
+ continue;
1035
+ }
1036
+ var symbols = Object.getOwnPropertySymbols(source);
1037
+ for (var j = 0; j < symbols.length; j++) {
1038
+ var symbol = symbols[j];
1039
+ if (propertyIsEnumerable.call(source, symbol)) {
1040
+ assignValue(source[symbol], symbol);
1041
+ }
1042
+ }
987
1043
  }
988
1044
  return result;
989
1045
  }
@@ -1000,8 +1056,8 @@
1000
1056
  * @returns {Object} The resulting value of object a
1001
1057
  */
1002
1058
  var extend = function extend(a, b, thisArg) {
1003
- var _ref3 = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {},
1004
- allOwnKeys = _ref3.allOwnKeys;
1059
+ var _ref4 = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {},
1060
+ allOwnKeys = _ref4.allOwnKeys;
1005
1061
  forEach(b, function (val, key) {
1006
1062
  if (thisArg && isFunction$1(val)) {
1007
1063
  Object.defineProperty(a, key, {
@@ -1195,14 +1251,7 @@
1195
1251
  return p1.toUpperCase() + p2;
1196
1252
  });
1197
1253
  };
1198
-
1199
- /* Creating a function that will check if an object has a property. */
1200
- var hasOwnProperty = function (_ref4) {
1201
- var hasOwnProperty = _ref4.hasOwnProperty;
1202
- return function (obj, prop) {
1203
- return hasOwnProperty.call(obj, prop);
1204
- };
1205
- }(Object.prototype);
1254
+ var propertyIsEnumerable = Object.prototype.propertyIsEnumerable;
1206
1255
 
1207
1256
  /**
1208
1257
  * Determine if a value is a RegExp object
@@ -1382,6 +1431,21 @@
1382
1431
  var isIterable = function isIterable(thing) {
1383
1432
  return thing != null && isFunction$1(thing[iterator]);
1384
1433
  };
1434
+
1435
+ /**
1436
+ * Determine if a value is iterable via an iterator that is NOT sourced solely
1437
+ * from a polluted Object.prototype. Use this instead of `isIterable` whenever
1438
+ * the iterable comes from untrusted input (e.g. user-supplied header sources),
1439
+ * so `Object.prototype[Symbol.iterator] = ...` cannot turn an ordinary object
1440
+ * into an attacker-controlled entries iterator.
1441
+ *
1442
+ * @param {*} thing The value to test
1443
+ *
1444
+ * @returns {boolean} True if value has a non-polluted iterator
1445
+ */
1446
+ var isSafeIterable = function isSafeIterable(thing) {
1447
+ return thing != null && hasOwnInPrototypeChain(thing, iterator) && isIterable(thing);
1448
+ };
1385
1449
  var utils$1 = {
1386
1450
  isArray: isArray,
1387
1451
  isArrayBuffer: isArrayBuffer,
@@ -1427,6 +1491,8 @@
1427
1491
  hasOwnProperty: hasOwnProperty,
1428
1492
  hasOwnProp: hasOwnProperty,
1429
1493
  // an alias to avoid ESLint no-prototype-builtins detection
1494
+ hasOwnInPrototypeChain: hasOwnInPrototypeChain,
1495
+ getSafeProp: getSafeProp,
1430
1496
  reduceDescriptors: reduceDescriptors,
1431
1497
  freezeMethods: freezeMethods,
1432
1498
  toObjectSet: toObjectSet,
@@ -1442,7 +1508,8 @@
1442
1508
  isThenable: isThenable,
1443
1509
  setImmediate: _setImmediate,
1444
1510
  asap: asap,
1445
- isIterable: isIterable
1511
+ isIterable: isIterable,
1512
+ isSafeIterable: isSafeIterable
1446
1513
  };
1447
1514
 
1448
1515
  // RawAxiosHeaders whose duplicates are ignored by node
@@ -1603,7 +1670,7 @@
1603
1670
  function setHeader(_value, _header, _rewrite) {
1604
1671
  var lHeader = normalizeHeader(_header);
1605
1672
  if (!lHeader) {
1606
- throw new Error('header name must be a non-empty string');
1673
+ return;
1607
1674
  }
1608
1675
  var key = utils$1.findKey(self, lHeader);
1609
1676
  if (!key || self[key] === undefined || _rewrite === true || _rewrite === undefined && self[key] !== false) {
@@ -1619,8 +1686,8 @@
1619
1686
  setHeaders(header, valueOrRewrite);
1620
1687
  } else if (utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
1621
1688
  setHeaders(parseHeaders(header), valueOrRewrite);
1622
- } else if (utils$1.isObject(header) && utils$1.isIterable(header)) {
1623
- var obj = {},
1689
+ } else if (utils$1.isObject(header) && utils$1.isSafeIterable(header)) {
1690
+ var obj = Object.create(null),
1624
1691
  dest,
1625
1692
  key;
1626
1693
  var _iterator = _createForOfIteratorHelper(header),
@@ -1629,9 +1696,15 @@
1629
1696
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
1630
1697
  var entry = _step.value;
1631
1698
  if (!utils$1.isArray(entry)) {
1632
- throw TypeError('Object iterator must return a key-value pair');
1699
+ throw new TypeError('Object iterator must return a key-value pair');
1700
+ }
1701
+ key = entry[0];
1702
+ if (utils$1.hasOwnProp(obj, key)) {
1703
+ dest = obj[key];
1704
+ obj[key] = utils$1.isArray(dest) ? [].concat(_toConsumableArray(dest), [entry[1]]) : [dest, entry[1]];
1705
+ } else {
1706
+ obj[key] = entry[1];
1633
1707
  }
1634
- obj[key = entry[0]] = (dest = obj[key]) ? utils$1.isArray(dest) ? [].concat(_toConsumableArray(dest), [entry[1]]) : [dest, entry[1]] : entry[1];
1635
1708
  }
1636
1709
  } catch (err) {
1637
1710
  _iterator.e(err);
@@ -1997,6 +2070,10 @@
1997
2070
  // eslint-disable-next-line strict
1998
2071
  var httpAdapter = null;
1999
2072
 
2073
+ // Default nesting limit shared with the inverse transform (formDataToJSON) so
2074
+ // the FormData <-> JSON round-trip stays symmetric.
2075
+ var DEFAULT_FORM_DATA_MAX_DEPTH = 100;
2076
+
2000
2077
  /**
2001
2078
  * Determines if the given thing is a array or js object.
2002
2079
  *
@@ -2097,8 +2174,9 @@
2097
2174
  var dots = options.dots;
2098
2175
  var indexes = options.indexes;
2099
2176
  var _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
2100
- var maxDepth = options.maxDepth === undefined ? 100 : options.maxDepth;
2177
+ var maxDepth = options.maxDepth === undefined ? DEFAULT_FORM_DATA_MAX_DEPTH : options.maxDepth;
2101
2178
  var useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
2179
+ var stack = [];
2102
2180
  if (!utils$1.isFunction(visitor)) {
2103
2181
  throw new TypeError('visitor must be a function');
2104
2182
  }
@@ -2118,6 +2196,28 @@
2118
2196
  }
2119
2197
  return value;
2120
2198
  }
2199
+ function throwIfMaxDepthExceeded(depth) {
2200
+ if (depth > maxDepth) {
2201
+ throw new AxiosError('Object is too deeply nested (' + depth + ' levels). Max depth: ' + maxDepth, AxiosError.ERR_FORM_DATA_DEPTH_EXCEEDED);
2202
+ }
2203
+ }
2204
+ function stringifyWithDepthLimit(value, depth) {
2205
+ if (maxDepth === Infinity) {
2206
+ return JSON.stringify(value);
2207
+ }
2208
+ var ancestors = [];
2209
+ return JSON.stringify(value, function limitDepth(_key, currentValue) {
2210
+ if (!utils$1.isObject(currentValue)) {
2211
+ return currentValue;
2212
+ }
2213
+ while (ancestors.length && ancestors[ancestors.length - 1] !== this) {
2214
+ ancestors.pop();
2215
+ }
2216
+ ancestors.push(currentValue);
2217
+ throwIfMaxDepthExceeded(depth + ancestors.length - 1);
2218
+ return currentValue;
2219
+ });
2220
+ }
2121
2221
 
2122
2222
  /**
2123
2223
  * Default visitor.
@@ -2140,7 +2240,7 @@
2140
2240
  // eslint-disable-next-line no-param-reassign
2141
2241
  key = metaTokens ? key : key.slice(0, -2);
2142
2242
  // eslint-disable-next-line no-param-reassign
2143
- value = JSON.stringify(value);
2243
+ value = stringifyWithDepthLimit(value, 1);
2144
2244
  } else if (utils$1.isArray(value) && isFlatArray(value) || (utils$1.isFileList(value) || utils$1.endsWith(key, '[]')) && (arr = utils$1.toArray(value))) {
2145
2245
  // eslint-disable-next-line no-param-reassign
2146
2246
  key = removeBrackets(key);
@@ -2158,7 +2258,6 @@
2158
2258
  formData.append(renderKey(path, key, dots), convertValue(value));
2159
2259
  return false;
2160
2260
  }
2161
- var stack = [];
2162
2261
  var exposedHelpers = Object.assign(predicates, {
2163
2262
  defaultVisitor: defaultVisitor,
2164
2263
  convertValue: convertValue,
@@ -2167,11 +2266,9 @@
2167
2266
  function build(value, path) {
2168
2267
  var depth = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
2169
2268
  if (utils$1.isUndefined(value)) return;
2170
- if (depth > maxDepth) {
2171
- throw new AxiosError('Object is too deeply nested (' + depth + ' levels). Max depth: ' + maxDepth, AxiosError.ERR_FORM_DATA_DEPTH_EXCEEDED);
2172
- }
2269
+ throwIfMaxDepthExceeded(depth);
2173
2270
  if (stack.indexOf(value) !== -1) {
2174
- throw Error('Circular reference detected in ' + path.join('.'));
2271
+ throw new Error('Circular reference detected in ' + path.join('.'));
2175
2272
  }
2176
2273
  stack.push(value);
2177
2274
  utils$1.forEach(value, function each(el, key) {
@@ -2261,11 +2358,15 @@
2261
2358
  if (!params) {
2262
2359
  return url;
2263
2360
  }
2264
- var _encode = options && options.encode || encode;
2265
2361
  var _options = utils$1.isFunction(options) ? {
2266
2362
  serialize: options
2267
2363
  } : options;
2268
- var serializeFn = _options && _options.serialize;
2364
+
2365
+ // Read serializer options pollution-safely: own properties and methods on a
2366
+ // class/template prototype are honored, but values injected onto a polluted
2367
+ // Object.prototype are ignored.
2368
+ var _encode = utils$1.getSafeProp(_options, 'encode') || encode;
2369
+ var serializeFn = utils$1.getSafeProp(_options, 'serialize');
2269
2370
  var serializedParams;
2270
2371
  if (serializeFn) {
2271
2372
  serializedParams = serializeFn(params, _options);
@@ -2363,7 +2464,9 @@
2363
2464
  silentJSONParsing: true,
2364
2465
  forcedJSONParsing: true,
2365
2466
  clarifyTimeoutError: false,
2366
- legacyInterceptorReqResOrdering: true
2467
+ legacyInterceptorReqResOrdering: true,
2468
+ advertiseZstdAcceptEncoding: false,
2469
+ validateStatusUndefinedResolves: true
2367
2470
  };
2368
2471
 
2369
2472
  var URLSearchParams$1 = typeof URLSearchParams !== 'undefined' ? URLSearchParams : AxiosURLSearchParams;
@@ -2443,6 +2546,13 @@
2443
2546
  }, options));
2444
2547
  }
2445
2548
 
2549
+ var MAX_DEPTH = DEFAULT_FORM_DATA_MAX_DEPTH;
2550
+ function throwIfDepthExceeded(index) {
2551
+ if (index > MAX_DEPTH) {
2552
+ throw new AxiosError('FormData field is too deeply nested (' + index + ' levels). Max depth: ' + MAX_DEPTH, AxiosError.ERR_FORM_DATA_DEPTH_EXCEEDED);
2553
+ }
2554
+ }
2555
+
2446
2556
  /**
2447
2557
  * It takes a string like `foo[x][y][z]` and returns an array like `['foo', 'x', 'y', 'z']
2448
2558
  *
@@ -2455,9 +2565,14 @@
2455
2565
  // foo.x.y.z
2456
2566
  // foo-x-y-z
2457
2567
  // foo x y z
2458
- return utils$1.matchAll(/\w+|\[(\w*)]/g, name).map(function (match) {
2459
- return match[0] === '[]' ? '' : match[1] || match[0];
2460
- });
2568
+ var path = [];
2569
+ var pattern = /\w+|\[(\w*)]/g;
2570
+ var match;
2571
+ while ((match = pattern.exec(name)) !== null) {
2572
+ throwIfDepthExceeded(path.length);
2573
+ path.push(match[0] === '[]' ? '' : match[1] || match[0]);
2574
+ }
2575
+ return path;
2461
2576
  }
2462
2577
 
2463
2578
  /**
@@ -2489,6 +2604,7 @@
2489
2604
  */
2490
2605
  function formDataToJSON(formData) {
2491
2606
  function buildPath(path, value, target, index) {
2607
+ throwIfDepthExceeded(index);
2492
2608
  var name = path[index++];
2493
2609
  if (name === '__proto__') return true;
2494
2610
  var isNumericKey = Number.isFinite(+name);
@@ -2936,6 +3052,24 @@
2936
3052
  return relativeURL ? baseURL.replace(/\/?\/$/, '') + '/' + relativeURL.replace(/^\/+/, '') : baseURL;
2937
3053
  }
2938
3054
 
3055
+ var malformedHttpProtocol = /^https?:(?!\/\/)/i;
3056
+ var httpProtocolControlCharacters = /[\t\n\r]/g;
3057
+ function stripLeadingC0ControlOrSpace(url) {
3058
+ var i = 0;
3059
+ while (i < url.length && url.charCodeAt(i) <= 0x20) {
3060
+ i++;
3061
+ }
3062
+ return url.slice(i);
3063
+ }
3064
+ function normalizeURLForProtocolCheck(url) {
3065
+ return stripLeadingC0ControlOrSpace(url).replace(httpProtocolControlCharacters, '');
3066
+ }
3067
+ function assertValidHttpProtocolURL(url, config) {
3068
+ if (typeof url === 'string' && malformedHttpProtocol.test(normalizeURLForProtocolCheck(url))) {
3069
+ throw new AxiosError('Invalid URL: missing "//" after protocol', AxiosError.ERR_INVALID_URL, config);
3070
+ }
3071
+ }
3072
+
2939
3073
  /**
2940
3074
  * Creates a new URL by combining the baseURL with the requestedURL,
2941
3075
  * only when the requestedURL is not already an absolute URL.
@@ -2946,9 +3080,11 @@
2946
3080
  *
2947
3081
  * @returns {string} The combined full path
2948
3082
  */
2949
- function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls) {
3083
+ function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls, config) {
3084
+ assertValidHttpProtocolURL(requestedURL, config);
2950
3085
  var isRelativeUrl = !isAbsoluteURL(requestedURL);
2951
3086
  if (baseURL && (isRelativeUrl || allowAbsoluteUrls === false)) {
3087
+ assertValidHttpProtocolURL(baseURL, config);
2952
3088
  return combineURLs(baseURL, requestedURL);
2953
3089
  }
2954
3090
  return requestedURL;
@@ -3020,6 +3156,23 @@
3020
3156
  return getMergedValue(undefined, a);
3021
3157
  }
3022
3158
  }
3159
+ function getMergedTransitionalOption(prop) {
3160
+ var transitional2 = utils$1.hasOwnProp(config2, 'transitional') ? config2.transitional : undefined;
3161
+ if (!utils$1.isUndefined(transitional2)) {
3162
+ if (utils$1.isPlainObject(transitional2)) {
3163
+ if (utils$1.hasOwnProp(transitional2, prop)) {
3164
+ return transitional2[prop];
3165
+ }
3166
+ } else {
3167
+ return undefined;
3168
+ }
3169
+ }
3170
+ var transitional1 = utils$1.hasOwnProp(config1, 'transitional') ? config1.transitional : undefined;
3171
+ if (utils$1.isPlainObject(transitional1) && utils$1.hasOwnProp(transitional1, prop)) {
3172
+ return transitional1[prop];
3173
+ }
3174
+ return undefined;
3175
+ }
3023
3176
 
3024
3177
  // eslint-disable-next-line consistent-return
3025
3178
  function mergeDirectKeys(a, b, prop) {
@@ -3071,6 +3224,13 @@
3071
3224
  var configValue = merge(a, b, prop);
3072
3225
  utils$1.isUndefined(configValue) && merge !== mergeDirectKeys || (config[prop] = configValue);
3073
3226
  });
3227
+ if (utils$1.hasOwnProp(config2, 'validateStatus') && utils$1.isUndefined(config2.validateStatus) && getMergedTransitionalOption('validateStatusUndefinedResolves') === false) {
3228
+ if (utils$1.hasOwnProp(config1, 'validateStatus')) {
3229
+ config.validateStatus = getMergedValue(undefined, config1.validateStatus);
3230
+ } else {
3231
+ delete config.validateStatus;
3232
+ }
3233
+ }
3074
3234
  return config;
3075
3235
  }
3076
3236
 
@@ -3098,12 +3258,12 @@
3098
3258
  *
3099
3259
  * @returns {string} UTF-8 bytes as a Latin-1 string
3100
3260
  */
3101
- var encodeUTF8 = function encodeUTF8(str) {
3261
+ var encodeUTF8$1 = function encodeUTF8(str) {
3102
3262
  return encodeURIComponent(str).replace(/%([0-9A-F]{2})/gi, function (_, hex) {
3103
3263
  return String.fromCharCode(parseInt(hex, 16));
3104
3264
  });
3105
3265
  };
3106
- var resolveConfig = (function (config) {
3266
+ function resolveConfig(config) {
3107
3267
  var newConfig = mergeConfig({}, config);
3108
3268
 
3109
3269
  // Read only own properties to prevent prototype pollution gadgets
@@ -3121,15 +3281,17 @@
3121
3281
  var allowAbsoluteUrls = own('allowAbsoluteUrls');
3122
3282
  var url = own('url');
3123
3283
  newConfig.headers = headers = AxiosHeaders.from(headers);
3124
- newConfig.url = buildURL(buildFullPath(baseURL, url, allowAbsoluteUrls), config.params, config.paramsSerializer);
3284
+ newConfig.url = buildURL(buildFullPath(baseURL, url, allowAbsoluteUrls, newConfig), own('params'), own('paramsSerializer'));
3125
3285
 
3126
3286
  // HTTP basic authentication
3127
3287
  if (auth) {
3128
- headers.set('Authorization', 'Basic ' + btoa((auth.username || '') + ':' + (auth.password ? encodeUTF8(auth.password) : '')));
3288
+ var username = utils$1.getSafeProp(auth, 'username') || '';
3289
+ var password = utils$1.getSafeProp(auth, 'password') || '';
3290
+ headers.set('Authorization', 'Basic ' + btoa(username + ':' + (password ? encodeUTF8$1(password) : '')));
3129
3291
  }
3130
3292
  if (utils$1.isFormData(data)) {
3131
- if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv) {
3132
- headers.setContentType(undefined); // browser handles it
3293
+ if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv || utils$1.isReactNative(data)) {
3294
+ headers.setContentType(undefined); // browser/web worker/RN handles it
3133
3295
  } else if (utils$1.isFunction(data.getHeaders)) {
3134
3296
  // Node.js FormData (like form-data package)
3135
3297
  setFormDataHeaders(headers, data.getHeaders(), own('formDataHeaderPolicy'));
@@ -3157,7 +3319,7 @@
3157
3319
  }
3158
3320
  }
3159
3321
  return newConfig;
3160
- });
3322
+ }
3161
3323
 
3162
3324
  var isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
3163
3325
  var xhrAdapter = isXHRAdapterSupported && function (config) {
@@ -3585,11 +3747,17 @@
3585
3747
  * Estimate decoded byte length of a data:// URL *without* allocating large buffers.
3586
3748
  * - For base64: compute exact decoded size using length and padding;
3587
3749
  * handle %XX at the character-count level (no string allocation).
3588
- * - For non-base64: use UTF-8 byteLength of the encoded body as a safe upper bound.
3750
+ * - For non-base64: compute the exact percent-decoded UTF-8 byte length.
3589
3751
  *
3590
3752
  * @param {string} url
3591
3753
  * @returns {number}
3592
3754
  */
3755
+ var isHexDigit = function isHexDigit(charCode) {
3756
+ return charCode >= 48 && charCode <= 57 || charCode >= 65 && charCode <= 70 || charCode >= 97 && charCode <= 102;
3757
+ };
3758
+ var isPercentEncodedByte = function isPercentEncodedByte(str, i, len) {
3759
+ return i + 2 < len && isHexDigit(str.charCodeAt(i + 1)) && isHexDigit(str.charCodeAt(i + 2));
3760
+ };
3593
3761
  function estimateDataURLDecodedBytes(url) {
3594
3762
  if (!url || typeof url !== 'string') return 0;
3595
3763
  if (!url.startsWith('data:')) return 0;
@@ -3606,7 +3774,7 @@
3606
3774
  if (body.charCodeAt(i) === 37 /* '%' */ && i + 2 < len) {
3607
3775
  var a = body.charCodeAt(i + 1);
3608
3776
  var b = body.charCodeAt(i + 2);
3609
- var isHex = (a >= 48 && a <= 57 || a >= 65 && a <= 70 || a >= 97 && a <= 102) && (b >= 48 && b <= 57 || b >= 65 && b <= 70 || b >= 97 && b <= 102);
3777
+ var isHex = isHexDigit(a) && isHexDigit(b);
3610
3778
  if (isHex) {
3611
3779
  effectiveLen -= 2;
3612
3780
  i += 2;
@@ -3643,18 +3811,18 @@
3643
3811
  var _bytes = groups * 3 - (pad || 0);
3644
3812
  return _bytes > 0 ? _bytes : 0;
3645
3813
  }
3646
- if (typeof Buffer !== 'undefined' && typeof Buffer.byteLength === 'function') {
3647
- return Buffer.byteLength(body, 'utf8');
3648
- }
3649
3814
 
3650
3815
  // Compute UTF-8 byte length directly from UTF-16 code units without allocating
3651
3816
  // a byte buffer (TextEncoder.encode would defeat the DoS guard on large bodies).
3652
- // Using body.length here would undercount non-ASCII (e.g. '€' is 1 code unit
3653
- // but 3 UTF-8 bytes).
3817
+ // Valid %XX triplets count as one decoded byte; this matches the bytes that
3818
+ // decodeURIComponent(body) would produce before Buffer re-encodes the string.
3654
3819
  var bytes = 0;
3655
3820
  for (var _i = 0, _len = body.length; _i < _len; _i++) {
3656
3821
  var c = body.charCodeAt(_i);
3657
- if (c < 0x80) {
3822
+ if (c === 37 /* '%' */ && isPercentEncodedByte(body, _i, _len)) {
3823
+ bytes += 1;
3824
+ _i += 2;
3825
+ } else if (c < 0x80) {
3658
3826
  bytes += 1;
3659
3827
  } else if (c < 0x800) {
3660
3828
  bytes += 2;
@@ -3673,10 +3841,39 @@
3673
3841
  return bytes;
3674
3842
  }
3675
3843
 
3676
- var VERSION = "1.16.1";
3844
+ var VERSION = "1.18.0";
3677
3845
 
3678
3846
  var DEFAULT_CHUNK_SIZE = 64 * 1024;
3679
3847
  var isFunction = utils$1.isFunction;
3848
+
3849
+ /**
3850
+ * Encode a UTF-8 string to a Latin-1 byte string for use with btoa().
3851
+ * This is a modern replacement for the deprecated unescape(encodeURIComponent(str)) pattern.
3852
+ *
3853
+ * @param {string} str The string to encode
3854
+ *
3855
+ * @returns {string} UTF-8 bytes as a Latin-1 string
3856
+ */
3857
+ var encodeUTF8 = function encodeUTF8(str) {
3858
+ return encodeURIComponent(str).replace(/%([0-9A-F]{2})/gi, function (_, hex) {
3859
+ return String.fromCharCode(parseInt(hex, 16));
3860
+ });
3861
+ };
3862
+
3863
+ // Node's WHATWG URL parser returns `username` and `password` percent-encoded.
3864
+ // Decode before composing the `auth` option so credentials such as
3865
+ // `my%40email.com:pass` are sent as `my@email.com:pass`. Falls back to the
3866
+ // original value for malformed input so a bad encoding never throws.
3867
+ var decodeURIComponentSafe = function decodeURIComponentSafe(value) {
3868
+ if (!utils$1.isString(value)) {
3869
+ return value;
3870
+ }
3871
+ try {
3872
+ return decodeURIComponent(value);
3873
+ } catch (error) {
3874
+ return value;
3875
+ }
3876
+ };
3680
3877
  var test = function test(fn) {
3681
3878
  try {
3682
3879
  for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
@@ -3687,6 +3884,14 @@
3687
3884
  return false;
3688
3885
  }
3689
3886
  };
3887
+ var maybeWithAuthCredentials = function maybeWithAuthCredentials(url) {
3888
+ var protocolIndex = url.indexOf('://');
3889
+ var urlToCheck = url;
3890
+ if (protocolIndex !== -1) {
3891
+ urlToCheck = urlToCheck.slice(protocolIndex + 3);
3892
+ }
3893
+ return urlToCheck.includes('@') || urlToCheck.includes(':');
3894
+ };
3690
3895
  var factory = function factory(env) {
3691
3896
  var globalObject = utils$1.global !== undefined && utils$1.global !== null ? utils$1.global : globalThis;
3692
3897
  var ReadableStream = globalObject.ReadableStream,
@@ -3840,13 +4045,16 @@
3840
4045
  }();
3841
4046
  return /*#__PURE__*/function () {
3842
4047
  var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(config) {
3843
- var _resolveConfig, url, method, data, signal, cancelToken, timeout, onDownloadProgress, onUploadProgress, responseType, headers, _resolveConfig$withCr, withCredentials, fetchOptions, maxContentLength, maxBodyLength, hasMaxContentLength, hasMaxBodyLength, _fetch, composedSignal, request, unsubscribe, requestContentLength, estimated, outboundLength, _request, contentTypeHeader, _progressEventDecorat, _progressEventDecorat2, onProgress, flush, isCredentialsSupported, contentType, resolvedOptions, response, declaredLength, isStreamResponse, options, responseContentLength, _ref5, _ref6, _onProgress, _flush, bytesRead, onChunkProgress, responseData, materializedSize, canceledError, _t3, _t4, _t5;
4048
+ var _resolveConfig, url, method, data, signal, cancelToken, timeout, onDownloadProgress, onUploadProgress, responseType, headers, _resolveConfig$withCr, withCredentials, fetchOptions, maxContentLength, maxBodyLength, hasMaxContentLength, hasMaxBodyLength, own, _fetch, composedSignal, request, unsubscribe, requestContentLength, pendingBodyError, maxBodyLengthError, auth, configAuth, username, password, parsedURL, urlUsername, urlPassword, estimated, outboundLength, mustEnforceStreamBody, trackRequestStream, _request, contentTypeHeader, _ref5, _ref6, onProgress, flush, isCredentialsSupported, contentType, resolvedOptions, response, responseHeaders, declaredLength, isStreamResponse, options, responseContentLength, _ref7, _ref8, _onProgress, _flush, bytesRead, onChunkProgress, responseData, materializedSize, canceledError, _t3, _t4;
3844
4049
  return _regenerator().w(function (_context4) {
3845
4050
  while (1) switch (_context4.p = _context4.n) {
3846
4051
  case 0:
3847
4052
  _resolveConfig = resolveConfig(config), url = _resolveConfig.url, method = _resolveConfig.method, data = _resolveConfig.data, signal = _resolveConfig.signal, cancelToken = _resolveConfig.cancelToken, timeout = _resolveConfig.timeout, onDownloadProgress = _resolveConfig.onDownloadProgress, onUploadProgress = _resolveConfig.onUploadProgress, responseType = _resolveConfig.responseType, headers = _resolveConfig.headers, _resolveConfig$withCr = _resolveConfig.withCredentials, withCredentials = _resolveConfig$withCr === void 0 ? 'same-origin' : _resolveConfig$withCr, fetchOptions = _resolveConfig.fetchOptions, maxContentLength = _resolveConfig.maxContentLength, maxBodyLength = _resolveConfig.maxBodyLength;
3848
4053
  hasMaxContentLength = utils$1.isNumber(maxContentLength) && maxContentLength > -1;
3849
4054
  hasMaxBodyLength = utils$1.isNumber(maxBodyLength) && maxBodyLength > -1;
4055
+ own = function own(key) {
4056
+ return utils$1.hasOwnProp(config, key) ? config[key] : undefined;
4057
+ };
3850
4058
  _fetch = envFetch || fetch;
3851
4059
  responseType = responseType ? (responseType + '').toLowerCase() : 'text';
3852
4060
  composedSignal = composeSignals([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
@@ -3854,7 +4062,50 @@
3854
4062
  unsubscribe = composedSignal && composedSignal.unsubscribe && function () {
3855
4063
  composedSignal.unsubscribe();
3856
4064
  };
4065
+ // AxiosError we raise while the request body is being streamed. Captured
4066
+ // by identity so the catch block can surface it directly, regardless of
4067
+ // how the runtime wraps the resulting fetch rejection (undici exposes it
4068
+ // as `err.cause`; some browsers drop the original error entirely).
4069
+ pendingBodyError = null;
4070
+ maxBodyLengthError = function maxBodyLengthError() {
4071
+ return new AxiosError('Request body larger than maxBodyLength limit', AxiosError.ERR_BAD_REQUEST, config, request);
4072
+ };
3857
4073
  _context4.p = 1;
4074
+ // HTTP basic authentication
4075
+ auth = undefined;
4076
+ configAuth = own('auth');
4077
+ if (configAuth) {
4078
+ username = utils$1.getSafeProp(configAuth, 'username') || '';
4079
+ password = utils$1.getSafeProp(configAuth, 'password') || '';
4080
+ auth = {
4081
+ username: username,
4082
+ password: password
4083
+ };
4084
+ }
4085
+ if (maybeWithAuthCredentials(url)) {
4086
+ parsedURL = new URL(url, platform.origin);
4087
+ if (!auth && (parsedURL.username || parsedURL.password)) {
4088
+ urlUsername = decodeURIComponentSafe(parsedURL.username);
4089
+ urlPassword = decodeURIComponentSafe(parsedURL.password);
4090
+ auth = {
4091
+ username: urlUsername,
4092
+ password: urlPassword
4093
+ };
4094
+ }
4095
+ if (parsedURL.username || parsedURL.password) {
4096
+ parsedURL.username = '';
4097
+ parsedURL.password = '';
4098
+ url = parsedURL.href;
4099
+ }
4100
+ }
4101
+ if (auth) {
4102
+ headers["delete"]('authorization');
4103
+ headers.set('Authorization', 'Basic ' + btoa(encodeUTF8((auth.username || '') + ':' + (auth.password || ''))));
4104
+ }
4105
+
4106
+ // Enforce maxContentLength for data: URLs up-front so we never materialize
4107
+ // an oversized payload. The HTTP adapter applies the same check (see http.js
4108
+ // "if (protocol === 'data:')" branch).
3858
4109
  if (!(hasMaxContentLength && typeof url === 'string' && url.startsWith('data:'))) {
3859
4110
  _context4.n = 2;
3860
4111
  break;
@@ -3871,43 +4122,82 @@
3871
4122
  break;
3872
4123
  }
3873
4124
  _context4.n = 3;
3874
- return resolveBodyLength(headers, data);
4125
+ return getBodyLength(data);
3875
4126
  case 3:
3876
4127
  outboundLength = _context4.v;
3877
- if (!(typeof outboundLength === 'number' && isFinite(outboundLength) && outboundLength > maxBodyLength)) {
4128
+ if (!(typeof outboundLength === 'number' && isFinite(outboundLength))) {
3878
4129
  _context4.n = 4;
3879
4130
  break;
3880
4131
  }
3881
- throw new AxiosError('Request body larger than maxBodyLength limit', AxiosError.ERR_BAD_REQUEST, config, request);
4132
+ requestContentLength = outboundLength;
4133
+ if (!(outboundLength > maxBodyLength)) {
4134
+ _context4.n = 4;
4135
+ break;
4136
+ }
4137
+ throw maxBodyLengthError();
3882
4138
  case 4:
3883
- _t3 = onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head';
3884
- if (!_t3) {
4139
+ // A streamed body under maxBodyLength must be counted as fetch consumes
4140
+ // it; its size is never trusted from a caller-declared Content-Length.
4141
+ mustEnforceStreamBody = hasMaxBodyLength && (utils$1.isReadableStream(data) || utils$1.isStream(data));
4142
+ trackRequestStream = function trackRequestStream(stream, onProgress, flush) {
4143
+ return trackStream(stream, DEFAULT_CHUNK_SIZE, function (loadedBytes) {
4144
+ if (hasMaxBodyLength && loadedBytes > maxBodyLength) {
4145
+ throw pendingBodyError = maxBodyLengthError();
4146
+ }
4147
+ onProgress && onProgress(loadedBytes);
4148
+ }, flush);
4149
+ };
4150
+ if (!(supportsRequestStream && method !== 'get' && method !== 'head' && (onUploadProgress || mustEnforceStreamBody))) {
4151
+ _context4.n = 8;
4152
+ break;
4153
+ }
4154
+ if (!(requestContentLength == null)) {
3885
4155
  _context4.n = 6;
3886
4156
  break;
3887
4157
  }
3888
4158
  _context4.n = 5;
3889
4159
  return resolveBodyLength(headers, data);
3890
4160
  case 5:
3891
- _t4 = requestContentLength = _context4.v;
3892
- _t3 = _t4 !== 0;
4161
+ _t3 = _context4.v;
4162
+ _context4.n = 7;
4163
+ break;
3893
4164
  case 6:
3894
- if (!_t3) {
3895
- _context4.n = 7;
3896
- break;
4165
+ _t3 = requestContentLength;
4166
+ case 7:
4167
+ requestContentLength = _t3;
4168
+ // A declared length of 0 is only trusted to skip the wrap when we are
4169
+ // not enforcing a stream limit (which must not rely on that header).
4170
+ if (requestContentLength !== 0 || mustEnforceStreamBody) {
4171
+ _request = new Request(url, {
4172
+ method: 'POST',
4173
+ body: data,
4174
+ duplex: 'half'
4175
+ });
4176
+ if (utils$1.isFormData(data) && (contentTypeHeader = _request.headers.get('content-type'))) {
4177
+ headers.setContentType(contentTypeHeader);
4178
+ }
4179
+ if (_request.body) {
4180
+ _ref5 = onUploadProgress && progressEventDecorator(requestContentLength, progressEventReducer(asyncDecorator(onUploadProgress))) || [], _ref6 = _slicedToArray(_ref5, 2), onProgress = _ref6[0], flush = _ref6[1];
4181
+ data = trackRequestStream(_request.body, onProgress, flush);
4182
+ }
3897
4183
  }
3898
- _request = new Request(url, {
3899
- method: 'POST',
3900
- body: data,
3901
- duplex: 'half'
3902
- });
3903
- if (utils$1.isFormData(data) && (contentTypeHeader = _request.headers.get('content-type'))) {
3904
- headers.setContentType(contentTypeHeader);
4184
+ _context4.n = 10;
4185
+ break;
4186
+ case 8:
4187
+ if (!(mustEnforceStreamBody && !isRequestSupported && isReadableStreamSupported && method !== 'get' && method !== 'head')) {
4188
+ _context4.n = 9;
4189
+ break;
3905
4190
  }
3906
- if (_request.body) {
3907
- _progressEventDecorat = progressEventDecorator(requestContentLength, progressEventReducer(asyncDecorator(onUploadProgress))), _progressEventDecorat2 = _slicedToArray(_progressEventDecorat, 2), onProgress = _progressEventDecorat2[0], flush = _progressEventDecorat2[1];
3908
- data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush);
4191
+ data = trackRequestStream(data);
4192
+ _context4.n = 10;
4193
+ break;
4194
+ case 9:
4195
+ if (!(mustEnforceStreamBody && isRequestSupported && !supportsRequestStream && method !== 'get' && method !== 'head')) {
4196
+ _context4.n = 10;
4197
+ break;
3909
4198
  }
3910
- case 7:
4199
+ throw new AxiosError('Stream request bodies are not supported by the current fetch implementation', AxiosError.ERR_NOT_SUPPORT, config, request);
4200
+ case 10:
3911
4201
  if (!utils$1.isString(withCredentials)) {
3912
4202
  withCredentials = withCredentials ? 'include' : 'omit';
3913
4203
  }
@@ -3934,29 +4224,31 @@
3934
4224
  credentials: isCredentialsSupported ? withCredentials : undefined
3935
4225
  });
3936
4226
  request = isRequestSupported && new Request(url, resolvedOptions);
3937
- _context4.n = 8;
4227
+ _context4.n = 11;
3938
4228
  return isRequestSupported ? _fetch(request, fetchOptions) : _fetch(url, resolvedOptions);
3939
- case 8:
4229
+ case 11:
3940
4230
  response = _context4.v;
4231
+ responseHeaders = AxiosHeaders.from(response.headers); // Cheap pre-check: if the server honestly declares a content-length that
4232
+ // already exceeds the cap, reject before we start streaming.
3941
4233
  if (!hasMaxContentLength) {
3942
- _context4.n = 9;
4234
+ _context4.n = 12;
3943
4235
  break;
3944
4236
  }
3945
- declaredLength = utils$1.toFiniteNumber(response.headers.get('content-length'));
4237
+ declaredLength = utils$1.toFiniteNumber(responseHeaders.getContentLength());
3946
4238
  if (!(declaredLength != null && declaredLength > maxContentLength)) {
3947
- _context4.n = 9;
4239
+ _context4.n = 12;
3948
4240
  break;
3949
4241
  }
3950
4242
  throw new AxiosError('maxContentLength size of ' + maxContentLength + ' exceeded', AxiosError.ERR_BAD_RESPONSE, config, request);
3951
- case 9:
4243
+ case 12:
3952
4244
  isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
3953
4245
  if (supportsResponseStream && response.body && (onDownloadProgress || hasMaxContentLength || isStreamResponse && unsubscribe)) {
3954
4246
  options = {};
3955
4247
  ['status', 'statusText', 'headers'].forEach(function (prop) {
3956
4248
  options[prop] = response[prop];
3957
4249
  });
3958
- responseContentLength = utils$1.toFiniteNumber(response.headers.get('content-length'));
3959
- _ref5 = onDownloadProgress && progressEventDecorator(responseContentLength, progressEventReducer(asyncDecorator(onDownloadProgress), true)) || [], _ref6 = _slicedToArray(_ref5, 2), _onProgress = _ref6[0], _flush = _ref6[1];
4250
+ responseContentLength = utils$1.toFiniteNumber(responseHeaders.getContentLength());
4251
+ _ref7 = onDownloadProgress && progressEventDecorator(responseContentLength, progressEventReducer(asyncDecorator(onDownloadProgress), true)) || [], _ref8 = _slicedToArray(_ref7, 2), _onProgress = _ref8[0], _flush = _ref8[1];
3960
4252
  bytesRead = 0;
3961
4253
  onChunkProgress = function onChunkProgress(loadedBytes) {
3962
4254
  if (hasMaxContentLength) {
@@ -3973,12 +4265,12 @@
3973
4265
  }), options);
3974
4266
  }
3975
4267
  responseType = responseType || 'text';
3976
- _context4.n = 10;
4268
+ _context4.n = 13;
3977
4269
  return resolvers[utils$1.findKey(resolvers, responseType) || 'text'](response, config);
3978
- case 10:
4270
+ case 13:
3979
4271
  responseData = _context4.v;
3980
4272
  if (!(hasMaxContentLength && !supportsResponseStream && !isStreamResponse)) {
3981
- _context4.n = 11;
4273
+ _context4.n = 14;
3982
4274
  break;
3983
4275
  }
3984
4276
  if (responseData != null) {
@@ -3991,13 +4283,13 @@
3991
4283
  }
3992
4284
  }
3993
4285
  if (!(typeof materializedSize === 'number' && materializedSize > maxContentLength)) {
3994
- _context4.n = 11;
4286
+ _context4.n = 14;
3995
4287
  break;
3996
4288
  }
3997
4289
  throw new AxiosError('maxContentLength size of ' + maxContentLength + ' exceeded', AxiosError.ERR_BAD_RESPONSE, config, request);
3998
- case 11:
4290
+ case 14:
3999
4291
  !isStreamResponse && unsubscribe && unsubscribe();
4000
- _context4.n = 12;
4292
+ _context4.n = 15;
4001
4293
  return new Promise(function (resolve, reject) {
4002
4294
  settle(resolve, reject, {
4003
4295
  data: responseData,
@@ -4008,39 +4300,53 @@
4008
4300
  request: request
4009
4301
  });
4010
4302
  });
4011
- case 12:
4303
+ case 15:
4012
4304
  return _context4.a(2, _context4.v);
4013
- case 13:
4014
- _context4.p = 13;
4015
- _t5 = _context4.v;
4305
+ case 16:
4306
+ _context4.p = 16;
4307
+ _t4 = _context4.v;
4016
4308
  unsubscribe && unsubscribe();
4017
4309
 
4018
4310
  // Safari can surface fetch aborts as a DOMException-like object whose
4019
4311
  // branded getters throw. Prefer our composed signal reason before reading
4020
4312
  // the caught error, preserving timeout vs cancellation semantics.
4021
4313
  if (!(composedSignal && composedSignal.aborted && composedSignal.reason instanceof AxiosError)) {
4022
- _context4.n = 14;
4314
+ _context4.n = 17;
4023
4315
  break;
4024
4316
  }
4025
4317
  canceledError = composedSignal.reason;
4026
4318
  canceledError.config = config;
4027
4319
  request && (canceledError.request = request);
4028
- _t5 !== canceledError && (canceledError.cause = _t5);
4320
+ _t4 !== canceledError && (canceledError.cause = _t4);
4029
4321
  throw canceledError;
4030
- case 14:
4031
- if (!(_t5 && _t5.name === 'TypeError' && /Load failed|fetch/i.test(_t5.message))) {
4032
- _context4.n = 15;
4322
+ case 17:
4323
+ if (!pendingBodyError) {
4324
+ _context4.n = 18;
4033
4325
  break;
4034
4326
  }
4035
- throw Object.assign(new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request, _t5 && _t5.response), {
4036
- cause: _t5.cause || _t5
4327
+ request && !pendingBodyError.request && (pendingBodyError.request = request);
4328
+ throw pendingBodyError;
4329
+ case 18:
4330
+ if (!(_t4 instanceof AxiosError)) {
4331
+ _context4.n = 19;
4332
+ break;
4333
+ }
4334
+ request && !_t4.request && (_t4.request = request);
4335
+ throw _t4;
4336
+ case 19:
4337
+ if (!(_t4 && _t4.name === 'TypeError' && /Load failed|fetch/i.test(_t4.message))) {
4338
+ _context4.n = 20;
4339
+ break;
4340
+ }
4341
+ throw Object.assign(new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request, _t4 && _t4.response), {
4342
+ cause: _t4.cause || _t4
4037
4343
  });
4038
- case 15:
4039
- throw AxiosError.from(_t5, _t5 && _t5.code, config, request, _t5 && _t5.response);
4040
- case 16:
4344
+ case 20:
4345
+ throw AxiosError.from(_t4, _t4 && _t4.code, config, request, _t4 && _t4.response);
4346
+ case 21:
4041
4347
  return _context4.a(2);
4042
4348
  }
4043
- }, _callee4, null, [[1, 13]]);
4349
+ }, _callee4, null, [[1, 16]]);
4044
4350
  }));
4045
4351
  return function (_x5) {
4046
4352
  return _ref4.apply(this, arguments);
@@ -4440,7 +4746,9 @@
4440
4746
  silentJSONParsing: validators.transitional(validators["boolean"]),
4441
4747
  forcedJSONParsing: validators.transitional(validators["boolean"]),
4442
4748
  clarifyTimeoutError: validators.transitional(validators["boolean"]),
4443
- legacyInterceptorReqResOrdering: validators.transitional(validators["boolean"])
4749
+ legacyInterceptorReqResOrdering: validators.transitional(validators["boolean"]),
4750
+ advertiseZstdAcceptEncoding: validators.transitional(validators["boolean"]),
4751
+ validateStatusUndefinedResolves: validators.transitional(validators["boolean"])
4444
4752
  }, false);
4445
4753
  }
4446
4754
  if (paramsSerializer != null) {
@@ -4539,7 +4847,7 @@
4539
4847
  key: "getUri",
4540
4848
  value: function getUri(config) {
4541
4849
  config = mergeConfig(this.defaults, config);
4542
- var fullPath = buildFullPath(config.baseURL, config.url, config.allowAbsoluteUrls);
4850
+ var fullPath = buildFullPath(config.baseURL, config.url, config.allowAbsoluteUrls, config);
4543
4851
  return buildURL(fullPath, config.params, config.paramsSerializer);
4544
4852
  }
4545
4853
  }]);
@@ -4550,7 +4858,7 @@
4550
4858
  return this.request(mergeConfig(config || {}, {
4551
4859
  method: method,
4552
4860
  url: url,
4553
- data: (config || {}).data
4861
+ data: config && utils$1.hasOwnProp(config, 'data') ? config.data : undefined
4554
4862
  }));
4555
4863
  };
4556
4864
  });