axios 1.18.1 → 1.19.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.18.1 Copyright (c) 2026 Matt Zabriskie and contributors */
1
+ /*! Axios v1.19.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) :
@@ -825,6 +825,7 @@
825
825
  * @returns {boolean} True if value is a FileList, otherwise false
826
826
  */
827
827
  var isFileList = kindOfTest('FileList');
828
+ var isSet = kindOfTest('Set');
828
829
 
829
830
  /**
830
831
  * Determine if a value is a Stream
@@ -1354,11 +1355,29 @@
1354
1355
  if (!('toJSON' in source)) {
1355
1356
  // add-on descent / delete-on-ascent: preserves path semantics, so DAG nodes serialise at every occurrence (see #7230).
1356
1357
  visited.add(source);
1357
- var target = isArray(source) ? [] : {};
1358
- forEach(source, function (value, key) {
1359
- var reducedValue = _visit(value);
1360
- !isUndefined(reducedValue) && (target[key] = reducedValue);
1361
- });
1358
+ var target;
1359
+ if (isSet(source)) {
1360
+ target = [];
1361
+ var _iterator2 = _createForOfIteratorHelper(source),
1362
+ _step;
1363
+ try {
1364
+ for (_iterator2.s(); !(_step = _iterator2.n()).done;) {
1365
+ var value = _step.value;
1366
+ var reducedValue = _visit(value);
1367
+ !isUndefined(reducedValue) && target.push(reducedValue);
1368
+ }
1369
+ } catch (err) {
1370
+ _iterator2.e(err);
1371
+ } finally {
1372
+ _iterator2.f();
1373
+ }
1374
+ } else {
1375
+ target = isArray(source) ? [] : {};
1376
+ forEach(source, function (value, key) {
1377
+ var reducedValue = _visit(value);
1378
+ !isUndefined(reducedValue) && (target[key] = reducedValue);
1379
+ });
1380
+ }
1362
1381
  visited["delete"](source);
1363
1382
  return target;
1364
1383
  }
@@ -1539,17 +1558,18 @@
1539
1558
  i = line.indexOf(':');
1540
1559
  key = line.substring(0, i).trim().toLowerCase();
1541
1560
  val = line.substring(i + 1).trim();
1542
- if (!key || parsed[key] && ignoreDuplicateOf[key]) {
1561
+ var hasKey = utils$1.hasOwnProp(parsed, key);
1562
+ if (!key || hasKey && utils$1.hasOwnProp(ignoreDuplicateOf, key)) {
1543
1563
  return;
1544
1564
  }
1545
1565
  if (key === 'set-cookie') {
1546
- if (parsed[key]) {
1566
+ if (hasKey) {
1547
1567
  parsed[key].push(val);
1548
1568
  } else {
1549
1569
  parsed[key] = [val];
1550
1570
  }
1551
1571
  } else {
1552
- parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
1572
+ parsed[key] = hasKey ? parsed[key] + ', ' + val : val;
1553
1573
  }
1554
1574
  });
1555
1575
  return parsed;
@@ -1621,6 +1641,90 @@
1621
1641
  }
1622
1642
  return tokens;
1623
1643
  }
1644
+ var parameterNameRE = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;
1645
+ function trimOWS(value) {
1646
+ var start = 0;
1647
+ var end = value.length;
1648
+ while (start < end) {
1649
+ var code = value.charCodeAt(start);
1650
+ if (code !== 0x09 && code !== 0x20) {
1651
+ break;
1652
+ }
1653
+ start += 1;
1654
+ }
1655
+ while (end > start) {
1656
+ var _code = value.charCodeAt(end - 1);
1657
+ if (_code !== 0x09 && _code !== 0x20) {
1658
+ break;
1659
+ }
1660
+ end -= 1;
1661
+ }
1662
+ return start === 0 && end === value.length ? value : value.slice(start, end);
1663
+ }
1664
+ function decodeQuotedString(value) {
1665
+ var last = value.length - 1;
1666
+ if (last < 1 || value.charCodeAt(0) !== 0x22 || value.charCodeAt(last) !== 0x22) {
1667
+ return value;
1668
+ }
1669
+ var decoded = '';
1670
+ for (var i = 1; i < last; i++) {
1671
+ var code = value.charCodeAt(i);
1672
+ if (code === 0x22) {
1673
+ return value;
1674
+ }
1675
+ if (code === 0x5c) {
1676
+ i += 1;
1677
+ if (i >= last) {
1678
+ return value;
1679
+ }
1680
+ }
1681
+ decoded += value[i];
1682
+ }
1683
+ return decoded;
1684
+ }
1685
+ function _parseParameters(value) {
1686
+ var parameters = Object.create(null);
1687
+ var str = String(value);
1688
+ var start = 0;
1689
+ var quoted = false;
1690
+ var escaped = false;
1691
+ function parseParameter(end) {
1692
+ var part = trimOWS(str.slice(start, end));
1693
+ var equals = part.indexOf('=');
1694
+ if (equals < 1) {
1695
+ return;
1696
+ }
1697
+ var name = trimOWS(part.slice(0, equals));
1698
+ if (!parameterNameRE.test(name)) {
1699
+ return;
1700
+ }
1701
+ var normalizedName = name.toLowerCase();
1702
+ if (normalizedName === '__proto__' || normalizedName === 'constructor' || normalizedName === 'prototype') {
1703
+ return;
1704
+ }
1705
+ var parameterValue = trimOWS(part.slice(equals + 1));
1706
+ parameters[normalizedName] = decodeQuotedString(parameterValue);
1707
+ }
1708
+ for (var i = 0; i < str.length; i++) {
1709
+ var code = str.charCodeAt(i);
1710
+ if (quoted) {
1711
+ if (escaped) {
1712
+ escaped = false;
1713
+ } else if (code === 0x5c) {
1714
+ escaped = true;
1715
+ } else if (code === 0x22) {
1716
+ quoted = false;
1717
+ }
1718
+ } else if (code === 0x22) {
1719
+ quoted = true;
1720
+ } else if (code === 0x2c || code === 0x3b) {
1721
+ parseParameter(i);
1722
+ start = i + 1;
1723
+ }
1724
+ }
1725
+ parseParameter(str.length);
1726
+ return parameters;
1727
+ }
1624
1728
  var isValidHeaderName = function isValidHeaderName(str) {
1625
1729
  return /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
1626
1730
  };
@@ -1845,7 +1949,8 @@
1845
1949
  }, {
1846
1950
  key: "getSetCookie",
1847
1951
  value: function getSetCookie() {
1848
- return this.get('set-cookie') || [];
1952
+ var value = this.get('set-cookie');
1953
+ return utils$1.isArray(value) ? value : value == null || value === false ? [] : [value];
1849
1954
  }
1850
1955
  }, {
1851
1956
  key: Symbol.toStringTag,
@@ -1857,6 +1962,11 @@
1857
1962
  value: function from(thing) {
1858
1963
  return thing instanceof this ? thing : new this(thing);
1859
1964
  }
1965
+ }, {
1966
+ key: "parseParameters",
1967
+ value: function parseParameters(value) {
1968
+ return _parseParameters(value);
1969
+ }
1860
1970
  }, {
1861
1971
  key: "concat",
1862
1972
  value: function concat(first) {
@@ -1967,6 +2077,23 @@
1967
2077
  };
1968
2078
  return _visit(config);
1969
2079
  }
2080
+ function stringifySafely$1(value) {
2081
+ try {
2082
+ return String(value);
2083
+ } catch (err) {
2084
+ return '';
2085
+ }
2086
+ }
2087
+ function aggregateErrorMessage(error) {
2088
+ var message = error.errors.map(function (entry) {
2089
+ try {
2090
+ return entry && entry.message ? stringifySafely$1(entry.message) : stringifySafely$1(entry);
2091
+ } catch (err) {
2092
+ return '';
2093
+ }
2094
+ }).filter(Boolean).join('; ');
2095
+ return message || error.name || 'AggregateError';
2096
+ }
1970
2097
  var AxiosError = /*#__PURE__*/function (_Error) {
1971
2098
  /**
1972
2099
  * Create an Error with the specified message, config, error code, request and response.
@@ -2039,7 +2166,14 @@
2039
2166
  }], [{
2040
2167
  key: "from",
2041
2168
  value: function from(error, code, config, request, response, customProps) {
2042
- var axiosError = new AxiosError(error.message, code || error.code, config, request, response);
2169
+ // `AggregateError` (thrown by Node on dual-stack/Happy-Eyeballs connection
2170
+ // failures) has an empty `message`; its detail lives in `errors[]`. Without
2171
+ // this, the wrapped error surfaces with a blank message (see #6721).
2172
+ var message = error.message;
2173
+ if (!message && utils$1.isArray(error.errors) && error.errors.length) {
2174
+ message = aggregateErrorMessage(error);
2175
+ }
2176
+ var axiosError = new AxiosError(message, code || error.code, config, request, response);
2043
2177
  // Match native `Error` `cause` semantics: non-enumerable. The wrapped
2044
2178
  // error often carries circular internals (sockets, requests, agents), so
2045
2179
  // an enumerable `cause` makes structured loggers (pino/winston) and any
@@ -2207,9 +2341,6 @@
2207
2341
  if (useBlob && typeof _Blob === 'function') {
2208
2342
  return new _Blob([value]);
2209
2343
  }
2210
- if (typeof Buffer !== 'undefined') {
2211
- return Buffer.from(value);
2212
- }
2213
2344
  throw new AxiosError('Blob is not supported. Use a Buffer instead.', AxiosError.ERR_NOT_SUPPORT);
2214
2345
  }
2215
2346
  return value;
@@ -2581,12 +2712,18 @@
2581
2712
  * @returns An array of strings.
2582
2713
  */
2583
2714
  function parsePropPath(name) {
2584
- // foo[x][y][z]
2585
- // foo.x.y.z
2586
- // foo-x-y-z
2587
- // foo x y z
2715
+ // foo[x][y][z] -> ['foo', 'x', 'y', 'z']
2716
+ // foo.x.y.z -> ['foo', 'x', 'y', 'z']
2717
+ // A path is split on `.` and on `[...]` groups. A segment — whether written
2718
+ // in dot notation or captured inside brackets — may contain any character
2719
+ // except `.`, `[` and `]`, so a key like `user-name` or `user name` is kept
2720
+ // literal instead of being split (#5402). `.`, `[` and `]` keep their existing
2721
+ // meaning, e.g. `foo[bar.baz]` -> ['foo', 'bar', 'baz'] and `[]` is an array push.
2722
+ // Excluding `[` from the bracket group also makes the match fail fast at the
2723
+ // next `[`, so a malformed name cannot rescan to the end of the string from
2724
+ // every unmatched `[` — parsing stays linear in the length of the name.
2588
2725
  var path = [];
2589
- var pattern = /\w+|\[(\w*)]/g;
2726
+ var pattern = /[^.[\]]+|\[([^.[\]]*)]/g;
2590
2727
  var match;
2591
2728
  while ((match = pattern.exec(name)) !== null) {
2592
2729
  throwIfDepthExceeded(path.length);
@@ -2943,7 +3080,7 @@
2943
3080
  }
2944
3081
  var rawLoaded = e.loaded;
2945
3082
  var total = e.lengthComputable ? e.total : undefined;
2946
- var loaded = total != null ? Math.min(rawLoaded, total) : rawLoaded;
3083
+ var loaded = Math.max(0, total != null ? Math.min(rawLoaded, total) : rawLoaded);
2947
3084
  var progressBytes = Math.max(0, loaded - bytesNotified);
2948
3085
  var rate = _speedometer(progressBytes);
2949
3086
  bytesNotified = Math.max(bytesNotified, loaded);
@@ -2971,11 +3108,12 @@
2971
3108
  }, throttled[1]];
2972
3109
  };
2973
3110
  var asyncDecorator = function asyncDecorator(fn) {
3111
+ var scheduler = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : utils$1.asap;
2974
3112
  return function () {
2975
3113
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
2976
3114
  args[_key] = arguments[_key];
2977
3115
  }
2978
- return utils$1.asap(function () {
3116
+ return scheduler(function () {
2979
3117
  return fn.apply(void 0, args);
2980
3118
  });
2981
3119
  };
@@ -3073,7 +3211,14 @@
3073
3211
  * @returns {string} The combined URL
3074
3212
  */
3075
3213
  function combineURLs(baseURL, relativeURL) {
3076
- return relativeURL ? baseURL.replace(/\/?\/$/, '') + '/' + relativeURL.replace(/^\/+/, '') : baseURL;
3214
+ if (!relativeURL) {
3215
+ return baseURL;
3216
+ }
3217
+ var end = baseURL.length;
3218
+ while (end > 0 && baseURL.charCodeAt(end - 1) === 47) {
3219
+ end--;
3220
+ }
3221
+ return baseURL.slice(0, end) + '/' + relativeURL.replace(/^\/+/, '');
3077
3222
  }
3078
3223
 
3079
3224
  var malformedHttpProtocol = /^https?:(?!\/\/)/i;
@@ -3088,9 +3233,40 @@
3088
3233
  function normalizeURLForProtocolCheck(url) {
3089
3234
  return stripLeadingC0ControlOrSpace(url).replace(httpProtocolControlCharacters, '');
3090
3235
  }
3236
+
3237
+ // Redact the parts of a URL that can carry secrets before it is embedded in an
3238
+ // error message. AxiosError.toJSON() serializes `message` verbatim and errors
3239
+ // are commonly logged, while the opt-in `config.redact` model only cleans
3240
+ // config keys — it cannot reach the message. Redact only the genuinely
3241
+ // sensitive substrings — userinfo (credentials), query parameter values and
3242
+ // fragment contents — with the same REDACTED marker the config redaction uses,
3243
+ // while keeping the scheme, host, path and parameter names so the offending
3244
+ // request stays accurately identifiable.
3245
+ function redactFragment(fragment) {
3246
+ if (!fragment) {
3247
+ return fragment;
3248
+ }
3249
+ return fragment.replace(/(^|&)([^=&]*=)?[^&]+/g, function (match, separator) {
3250
+ var parameterName = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
3251
+ return "".concat(separator).concat(parameterName).concat(REDACTED);
3252
+ });
3253
+ }
3254
+ function redactSensitiveURLParts(url) {
3255
+ var redactedURL = url.replace(/^(https?:\/{0,2})[^/?#]*@/i, "$1".concat(REDACTED, "@"));
3256
+ var fragmentIndex = redactedURL.indexOf('#');
3257
+ var urlWithoutFragment = fragmentIndex === -1 ? redactedURL : redactedURL.slice(0, fragmentIndex);
3258
+ var redactedURLWithoutFragment = urlWithoutFragment.replace(/([?&][^=&#]*=)[^&#]*/g, "$1".concat(REDACTED));
3259
+ if (fragmentIndex === -1) {
3260
+ return redactedURLWithoutFragment;
3261
+ }
3262
+ return "".concat(redactedURLWithoutFragment, "#").concat(redactFragment(redactedURL.slice(fragmentIndex + 1)));
3263
+ }
3091
3264
  function assertValidHttpProtocolURL(url, config) {
3092
- if (typeof url === 'string' && malformedHttpProtocol.test(normalizeURLForProtocolCheck(url))) {
3093
- throw new AxiosError('Invalid URL: missing "//" after protocol', AxiosError.ERR_INVALID_URL, config);
3265
+ if (typeof url === 'string') {
3266
+ var normalizedURL = normalizeURLForProtocolCheck(url);
3267
+ if (malformedHttpProtocol.test(normalizedURL)) {
3268
+ throw new AxiosError("Invalid URL ".concat(JSON.stringify(redactSensitiveURLParts(normalizedURL)), ": missing \"//\" after protocol"), AxiosError.ERR_INVALID_URL, config);
3269
+ }
3094
3270
  }
3095
3271
  }
3096
3272
 
@@ -3117,6 +3293,14 @@
3117
3293
  var headersToObject = function headersToObject(thing) {
3118
3294
  return thing instanceof AxiosHeaders ? _objectSpread2({}, thing) : thing;
3119
3295
  };
3296
+ var ownEnumerableKeys = function ownEnumerableKeys(thing) {
3297
+ if (Object.getOwnPropertySymbols && Object.getOwnPropertyDescriptor) {
3298
+ return Object.keys(thing).concat(Object.getOwnPropertySymbols(thing).filter(function (symbol) {
3299
+ return Object.getOwnPropertyDescriptor(thing, symbol).enumerable;
3300
+ }));
3301
+ }
3302
+ return Object.keys(thing);
3303
+ };
3120
3304
 
3121
3305
  /**
3122
3306
  * Config-specific merge-function which creates a new config-object
@@ -3241,7 +3425,7 @@
3241
3425
  return mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true);
3242
3426
  }
3243
3427
  };
3244
- utils$1.forEach(Object.keys(_objectSpread2(_objectSpread2({}, config1), config2)), function computeConfigValue(prop) {
3428
+ utils$1.forEach(ownEnumerableKeys(_objectSpread2(_objectSpread2({}, config1), config2)), function computeConfigValue(prop) {
3245
3429
  if (prop === '__proto__' || prop === 'constructor' || prop === 'prototype') return;
3246
3430
  var merge = utils$1.hasOwnProp(mergeMap, prop) ? mergeMap[prop] : mergeDeepProperties;
3247
3431
  var a = utils$1.hasOwnProp(config1, prop) ? config1[prop] : undefined;
@@ -3260,6 +3444,18 @@
3260
3444
  }
3261
3445
 
3262
3446
  var FORM_DATA_CONTENT_HEADERS = ['content-type', 'content-length'];
3447
+
3448
+ /**
3449
+ * Apply the headers generated by a FormData implementation to the request headers,
3450
+ * honoring the `formDataHeaderPolicy` option: with 'content-only', copy only the
3451
+ * content-* headers; otherwise merge all of them.
3452
+ *
3453
+ * @param {AxiosHeaders} headers - the request headers to mutate
3454
+ * @param {Object | null | undefined} formHeaders - headers produced by the FormData implementation
3455
+ * @param {String} [policy] - the resolved `formDataHeaderPolicy` config value
3456
+ *
3457
+ * @returns {void}
3458
+ */
3263
3459
  function setFormDataHeaders(headers, formHeaders, policy) {
3264
3460
  if (policy !== 'content-only') {
3265
3461
  headers.set(formHeaders);
@@ -3561,7 +3757,14 @@
3561
3757
  signals = null;
3562
3758
  };
3563
3759
  signals.forEach(function (signal) {
3564
- return signal.addEventListener('abort', onabort, {
3760
+ if (aborted) {
3761
+ return;
3762
+ }
3763
+ if (signal.aborted) {
3764
+ onabort.call(signal);
3765
+ return;
3766
+ }
3767
+ signal.addEventListener('abort', onabort, {
3565
3768
  once: true
3566
3769
  });
3567
3770
  });
@@ -3776,13 +3979,11 @@
3776
3979
  };
3777
3980
 
3778
3981
  /**
3779
- * Estimate decoded byte length of a data:// URL *without* allocating large buffers.
3780
- * - For base64: compute exact decoded size using length and padding;
3781
- * handle %XX at the character-count level (no string allocation).
3782
- * - For non-base64: compute the exact percent-decoded UTF-8 byte length.
3783
- *
3784
- * @param {string} url
3785
- * @returns {number}
3982
+ * Estimate data: URL byte lengths *without* allocating large buffers.
3983
+ * - Fetch percent-decodes a base64 body before decoding it.
3984
+ * - Node's Buffer.from(body, 'base64') sizes its backing allocation from the
3985
+ * raw body, including ignored characters and content after padding.
3986
+ * - Non-base64 data is percent-decoded and then encoded as UTF-8.
3786
3987
  */
3787
3988
  var isHexDigit = function isHexDigit(charCode) {
3788
3989
  return charCode >= 48 && charCode <= 57 || charCode >= 65 && charCode <= 70 || charCode >= 97 && charCode <= 102;
@@ -3790,7 +3991,80 @@
3790
3991
  var isPercentEncodedByte = function isPercentEncodedByte(str, i, len) {
3791
3992
  return i + 2 < len && isHexDigit(str.charCodeAt(i + 1)) && isHexDigit(str.charCodeAt(i + 2));
3792
3993
  };
3793
- function estimateDataURLDecodedBytes(url) {
3994
+ var hexValue = function hexValue(charCode) {
3995
+ return charCode <= 57 ? charCode - 48 : (charCode & 0xdf) - 55;
3996
+ };
3997
+ var isBase64Char = function isBase64Char(charCode) {
3998
+ return charCode >= 65 && charCode <= 90 ||
3999
+ // A-Z
4000
+ charCode >= 97 && charCode <= 122 ||
4001
+ // a-z
4002
+ charCode >= 48 && charCode <= 57 ||
4003
+ // 0-9
4004
+ charCode === 43 ||
4005
+ // +
4006
+ charCode === 47 ||
4007
+ // /
4008
+ charCode === 45 ||
4009
+ // - (base64url)
4010
+ charCode === 95;
4011
+ }; // _ (base64url)
4012
+
4013
+ var isBase64Whitespace = function isBase64Whitespace(charCode) {
4014
+ return charCode === 9 || charCode === 10 || charCode === 12 || charCode === 13 || charCode === 32;
4015
+ };
4016
+ var base64Bytes = function base64Bytes(significant) {
4017
+ var groups = Math.floor(significant / 4);
4018
+ var remainder = significant % 4;
4019
+ return groups * 3 + (remainder === 2 ? 1 : remainder === 3 ? 2 : 0);
4020
+ };
4021
+
4022
+ // Buffer.byteLength(body, 'base64') uses the raw string length as an allocation
4023
+ // upper bound even when Buffer.from later ignores characters or stops at '='.
4024
+ var estimateBase64BufferAllocation = function estimateBase64BufferAllocation(body) {
4025
+ var len = body.length;
4026
+ var padding = 0;
4027
+ if (len > 0 && body.charCodeAt(len - 1) === 61 /* '=' */) {
4028
+ padding++;
4029
+ if (len > 1 && body.charCodeAt(len - 2) === 61 /* '=' */) {
4030
+ padding++;
4031
+ }
4032
+ }
4033
+ return Math.floor((len - padding) * 3 / 4);
4034
+ };
4035
+ var estimatePercentDecodedBase64Bytes = function estimatePercentDecodedBase64Bytes(body) {
4036
+ var len = body.length;
4037
+ var significant = 0;
4038
+ var padding = 0;
4039
+ var invalid = false;
4040
+ for (var i = 0; i < len; i++) {
4041
+ var code = body.charCodeAt(i);
4042
+ if (code === 37 /* '%' */ && isPercentEncodedByte(body, i, len)) {
4043
+ code = hexValue(body.charCodeAt(i + 1)) * 16 + hexValue(body.charCodeAt(i + 2));
4044
+ i += 2;
4045
+ }
4046
+ if (isBase64Whitespace(code)) {
4047
+ continue;
4048
+ }
4049
+ if (code === 61 /* '=' */) {
4050
+ padding++;
4051
+ continue;
4052
+ }
4053
+ if (!isBase64Char(code) || padding > 0) {
4054
+ invalid = true;
4055
+ continue;
4056
+ }
4057
+ significant++;
4058
+ }
4059
+
4060
+ // Fetch rejects malformed forgiving-base64 input. Returning the raw-size
4061
+ // allocation bound keeps that invalid input from becoming a pre-check bypass.
4062
+ if (invalid || padding > 2 || padding > 0 && (significant + padding) % 4 !== 0 || significant % 4 === 1) {
4063
+ return estimateBase64BufferAllocation(body);
4064
+ }
4065
+ return base64Bytes(significant);
4066
+ };
4067
+ var estimateDataURLBytes = function estimateDataURLBytes(url, estimateBase64) {
3794
4068
  if (!url || typeof url !== 'string') return 0;
3795
4069
  if (!url.startsWith('data:')) return 0;
3796
4070
  var comma = url.indexOf(',');
@@ -3799,49 +4073,7 @@
3799
4073
  var body = url.slice(comma + 1);
3800
4074
  var isBase64 = /;base64/i.test(meta);
3801
4075
  if (isBase64) {
3802
- var effectiveLen = body.length;
3803
- var len = body.length; // cache length
3804
-
3805
- for (var i = 0; i < len; i++) {
3806
- if (body.charCodeAt(i) === 37 /* '%' */ && i + 2 < len) {
3807
- var a = body.charCodeAt(i + 1);
3808
- var b = body.charCodeAt(i + 2);
3809
- var isHex = isHexDigit(a) && isHexDigit(b);
3810
- if (isHex) {
3811
- effectiveLen -= 2;
3812
- i += 2;
3813
- }
3814
- }
3815
- }
3816
- var pad = 0;
3817
- var idx = len - 1;
3818
- var tailIsPct3D = function tailIsPct3D(j) {
3819
- return j >= 2 && body.charCodeAt(j - 2) === 37 &&
3820
- // '%'
3821
- body.charCodeAt(j - 1) === 51 && (
3822
- // '3'
3823
- body.charCodeAt(j) === 68 || body.charCodeAt(j) === 100);
3824
- }; // 'D' or 'd'
3825
-
3826
- if (idx >= 0) {
3827
- if (body.charCodeAt(idx) === 61 /* '=' */) {
3828
- pad++;
3829
- idx--;
3830
- } else if (tailIsPct3D(idx)) {
3831
- pad++;
3832
- idx -= 3;
3833
- }
3834
- }
3835
- if (pad === 1 && idx >= 0) {
3836
- if (body.charCodeAt(idx) === 61 /* '=' */) {
3837
- pad++;
3838
- } else if (tailIsPct3D(idx)) {
3839
- pad++;
3840
- }
3841
- }
3842
- var groups = Math.floor(effectiveLen / 4);
3843
- var _bytes = groups * 3 - (pad || 0);
3844
- return _bytes > 0 ? _bytes : 0;
4076
+ return estimateBase64(body);
3845
4077
  }
3846
4078
 
3847
4079
  // Compute UTF-8 byte length directly from UTF-16 code units without allocating
@@ -3849,20 +4081,20 @@
3849
4081
  // Valid %XX triplets count as one decoded byte; this matches the bytes that
3850
4082
  // decodeURIComponent(body) would produce before Buffer re-encodes the string.
3851
4083
  var bytes = 0;
3852
- for (var _i = 0, _len = body.length; _i < _len; _i++) {
3853
- var c = body.charCodeAt(_i);
3854
- if (c === 37 /* '%' */ && isPercentEncodedByte(body, _i, _len)) {
4084
+ for (var i = 0, len = body.length; i < len; i++) {
4085
+ var c = body.charCodeAt(i);
4086
+ if (c === 37 /* '%' */ && isPercentEncodedByte(body, i, len)) {
3855
4087
  bytes += 1;
3856
- _i += 2;
4088
+ i += 2;
3857
4089
  } else if (c < 0x80) {
3858
4090
  bytes += 1;
3859
4091
  } else if (c < 0x800) {
3860
4092
  bytes += 2;
3861
- } else if (c >= 0xd800 && c <= 0xdbff && _i + 1 < _len) {
3862
- var next = body.charCodeAt(_i + 1);
4093
+ } else if (c >= 0xd800 && c <= 0xdbff && i + 1 < len) {
4094
+ var next = body.charCodeAt(i + 1);
3863
4095
  if (next >= 0xdc00 && next <= 0xdfff) {
3864
4096
  bytes += 4;
3865
- _i++;
4097
+ i++;
3866
4098
  } else {
3867
4099
  bytes += 3;
3868
4100
  }
@@ -3871,9 +4103,21 @@
3871
4103
  }
3872
4104
  }
3873
4105
  return bytes;
4106
+ };
4107
+
4108
+ /**
4109
+ * Estimate the percent-decoded payload size used by Fetch data: URLs.
4110
+ *
4111
+ * @param {string} url
4112
+ * @returns {number}
4113
+ */
4114
+ function estimateDataURLDecodedBytes(url) {
4115
+ // Fetch removes URL fragments before processing a data: URL.
4116
+ var fragmentIndex = typeof url === 'string' ? url.indexOf('#') : -1;
4117
+ return estimateDataURLBytes(fragmentIndex === -1 ? url : url.slice(0, fragmentIndex), estimatePercentDecodedBase64Bytes);
3874
4118
  }
3875
4119
 
3876
- var VERSION = "1.18.1";
4120
+ var VERSION = "1.19.0";
3877
4121
 
3878
4122
  var DEFAULT_CHUNK_SIZE = 64 * 1024;
3879
4123
  var isFunction = utils$1.isFunction;
@@ -4777,6 +5021,7 @@
4777
5021
  }, {
4778
5022
  key: "_request",
4779
5023
  value: function _request(configOrUrl, config) {
5024
+ var _this = this;
4780
5025
  /*eslint no-param-reassign:0*/
4781
5026
  // Allow for axios('example/url'[, config]) a la fetch API
4782
5027
  if (typeof configOrUrl === 'string') {
@@ -4874,16 +5119,31 @@
4874
5119
  var onFulfilled = requestInterceptorChain[i++];
4875
5120
  var onRejected = requestInterceptorChain[i++];
4876
5121
  try {
4877
- newConfig = onFulfilled(newConfig);
5122
+ newConfig = onFulfilled ? onFulfilled(newConfig) : newConfig;
4878
5123
  } catch (error) {
4879
- onRejected.call(this, error);
5124
+ if (!onRejected) {
5125
+ promise = Promise.reject(error);
5126
+ break;
5127
+ }
5128
+ try {
5129
+ var rejectedResult = onRejected.call(this, error);
5130
+ if (utils$1.isThenable(rejectedResult)) {
5131
+ promise = Promise.resolve(rejectedResult).then(function () {
5132
+ return dispatchRequest.call(_this, newConfig);
5133
+ });
5134
+ }
5135
+ } catch (rejectedError) {
5136
+ promise = Promise.reject(rejectedError);
5137
+ }
4880
5138
  break;
4881
5139
  }
4882
5140
  }
4883
- try {
4884
- promise = dispatchRequest.call(this, newConfig);
4885
- } catch (error) {
4886
- return Promise.reject(error);
5141
+ if (!promise) {
5142
+ try {
5143
+ promise = dispatchRequest.call(this, newConfig);
5144
+ } catch (error) {
5145
+ promise = Promise.reject(error);
5146
+ }
4887
5147
  }
4888
5148
  i = 0;
4889
5149
  len = responseInterceptorChain.length;
@@ -5163,6 +5423,7 @@
5163
5423
  LoopDetected: 508,
5164
5424
  NotExtended: 510,
5165
5425
  NetworkAuthenticationRequired: 511,
5426
+ WebServerReturnsAnUnknownError: 520,
5166
5427
  WebServerIsDown: 521,
5167
5428
  ConnectionTimedOut: 522,
5168
5429
  OriginIsUnreachable: 523,
@@ -5246,4 +5507,3 @@
5246
5507
  return axios;
5247
5508
 
5248
5509
  }));
5249
- //# sourceMappingURL=axios.js.map