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/esm/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
  /**
3
3
  * Create a bound version of a function with a specified `this` context
4
4
  *
@@ -292,6 +292,7 @@ const isBlob = kindOfTest('Blob');
292
292
  * @returns {boolean} True if value is a FileList, otherwise false
293
293
  */
294
294
  const isFileList = kindOfTest('FileList');
295
+ const isSet = kindOfTest('Set');
295
296
 
296
297
  /**
297
298
  * Determine if a value is a Stream
@@ -857,12 +858,23 @@ const toJSONObject = (obj) => {
857
858
  if (!('toJSON' in source)) {
858
859
  // add-on descent / delete-on-ascent: preserves path semantics, so DAG nodes serialise at every occurrence (see #7230).
859
860
  visited.add(source);
860
- const target = isArray(source) ? [] : {};
861
861
 
862
- forEach(source, (value, key) => {
863
- const reducedValue = visit(value);
864
- !isUndefined(reducedValue) && (target[key] = reducedValue);
865
- });
862
+ let target;
863
+
864
+ if (isSet(source)) {
865
+ target = [];
866
+ for (const value of source) {
867
+ const reducedValue = visit(value);
868
+ !isUndefined(reducedValue) && target.push(reducedValue);
869
+ }
870
+ } else {
871
+ target = isArray(source) ? [] : {};
872
+
873
+ forEach(source, (value, key) => {
874
+ const reducedValue = visit(value);
875
+ !isUndefined(reducedValue) && (target[key] = reducedValue);
876
+ });
877
+ }
866
878
 
867
879
  visited.delete(source);
868
880
 
@@ -1074,18 +1086,20 @@ var parseHeaders = (rawHeaders) => {
1074
1086
  key = line.substring(0, i).trim().toLowerCase();
1075
1087
  val = line.substring(i + 1).trim();
1076
1088
 
1077
- if (!key || (parsed[key] && ignoreDuplicateOf[key])) {
1089
+ const hasKey = utils$1.hasOwnProp(parsed, key);
1090
+
1091
+ if (!key || (hasKey && utils$1.hasOwnProp(ignoreDuplicateOf, key))) {
1078
1092
  return;
1079
1093
  }
1080
1094
 
1081
1095
  if (key === 'set-cookie') {
1082
- if (parsed[key]) {
1096
+ if (hasKey) {
1083
1097
  parsed[key].push(val);
1084
1098
  } else {
1085
1099
  parsed[key] = [val];
1086
1100
  }
1087
1101
  } else {
1088
- parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
1102
+ parsed[key] = hasKey ? parsed[key] + ', ' + val : val;
1089
1103
  }
1090
1104
  });
1091
1105
 
@@ -1175,6 +1189,124 @@ function parseTokens(str) {
1175
1189
  return tokens;
1176
1190
  }
1177
1191
 
1192
+ const parameterNameRE = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;
1193
+
1194
+ function trimOWS(value) {
1195
+ let start = 0;
1196
+ let end = value.length;
1197
+
1198
+ while (start < end) {
1199
+ const code = value.charCodeAt(start);
1200
+
1201
+ if (code !== 0x09 && code !== 0x20) {
1202
+ break;
1203
+ }
1204
+
1205
+ start += 1;
1206
+ }
1207
+
1208
+ while (end > start) {
1209
+ const code = value.charCodeAt(end - 1);
1210
+
1211
+ if (code !== 0x09 && code !== 0x20) {
1212
+ break;
1213
+ }
1214
+
1215
+ end -= 1;
1216
+ }
1217
+
1218
+ return start === 0 && end === value.length ? value : value.slice(start, end);
1219
+ }
1220
+
1221
+ function decodeQuotedString(value) {
1222
+ const last = value.length - 1;
1223
+
1224
+ if (last < 1 || value.charCodeAt(0) !== 0x22 || value.charCodeAt(last) !== 0x22) {
1225
+ return value;
1226
+ }
1227
+
1228
+ let decoded = '';
1229
+
1230
+ for (let i = 1; i < last; i++) {
1231
+ const code = value.charCodeAt(i);
1232
+
1233
+ if (code === 0x22) {
1234
+ return value;
1235
+ }
1236
+
1237
+ if (code === 0x5c) {
1238
+ i += 1;
1239
+
1240
+ if (i >= last) {
1241
+ return value;
1242
+ }
1243
+ }
1244
+
1245
+ decoded += value[i];
1246
+ }
1247
+
1248
+ return decoded;
1249
+ }
1250
+
1251
+ function parseParameters(value) {
1252
+ const parameters = Object.create(null);
1253
+ const str = String(value);
1254
+ let start = 0;
1255
+ let quoted = false;
1256
+ let escaped = false;
1257
+
1258
+ function parseParameter(end) {
1259
+ const part = trimOWS(str.slice(start, end));
1260
+ const equals = part.indexOf('=');
1261
+
1262
+ if (equals < 1) {
1263
+ return;
1264
+ }
1265
+
1266
+ const name = trimOWS(part.slice(0, equals));
1267
+
1268
+ if (!parameterNameRE.test(name)) {
1269
+ return;
1270
+ }
1271
+
1272
+ const normalizedName = name.toLowerCase();
1273
+
1274
+ if (
1275
+ normalizedName === '__proto__' ||
1276
+ normalizedName === 'constructor' ||
1277
+ normalizedName === 'prototype'
1278
+ ) {
1279
+ return;
1280
+ }
1281
+
1282
+ const parameterValue = trimOWS(part.slice(equals + 1));
1283
+ parameters[normalizedName] = decodeQuotedString(parameterValue);
1284
+ }
1285
+
1286
+ for (let i = 0; i < str.length; i++) {
1287
+ const code = str.charCodeAt(i);
1288
+
1289
+ if (quoted) {
1290
+ if (escaped) {
1291
+ escaped = false;
1292
+ } else if (code === 0x5c) {
1293
+ escaped = true;
1294
+ } else if (code === 0x22) {
1295
+ quoted = false;
1296
+ }
1297
+ } else if (code === 0x22) {
1298
+ quoted = true;
1299
+ } else if (code === 0x2c || code === 0x3b) {
1300
+ parseParameter(i);
1301
+ start = i + 1;
1302
+ }
1303
+ }
1304
+
1305
+ parseParameter(str.length);
1306
+
1307
+ return parameters;
1308
+ }
1309
+
1178
1310
  const isValidHeaderName = (str) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
1179
1311
 
1180
1312
  function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
@@ -1426,7 +1558,8 @@ let AxiosHeaders$1 = class AxiosHeaders {
1426
1558
  }
1427
1559
 
1428
1560
  getSetCookie() {
1429
- return this.get('set-cookie') || [];
1561
+ const value = this.get('set-cookie');
1562
+ return utils$1.isArray(value) ? value : value == null || value === false ? [] : [value];
1430
1563
  }
1431
1564
 
1432
1565
  get [Symbol.toStringTag]() {
@@ -1437,6 +1570,10 @@ let AxiosHeaders$1 = class AxiosHeaders {
1437
1570
  return thing instanceof this ? thing : new this(thing);
1438
1571
  }
1439
1572
 
1573
+ static parseParameters(value) {
1574
+ return parseParameters(value);
1575
+ }
1576
+
1440
1577
  static concat(first, ...targets) {
1441
1578
  const computed = new this(first);
1442
1579
 
@@ -1562,9 +1699,40 @@ function redactConfig(config, redactKeys) {
1562
1699
  return visit(config);
1563
1700
  }
1564
1701
 
1702
+ function stringifySafely$1(value) {
1703
+ try {
1704
+ return String(value);
1705
+ } catch (err) {
1706
+ return '';
1707
+ }
1708
+ }
1709
+
1710
+ function aggregateErrorMessage(error) {
1711
+ const message = error.errors
1712
+ .map((entry) => {
1713
+ try {
1714
+ return entry && entry.message ? stringifySafely$1(entry.message) : stringifySafely$1(entry);
1715
+ } catch (err) {
1716
+ return '';
1717
+ }
1718
+ })
1719
+ .filter(Boolean)
1720
+ .join('; ');
1721
+
1722
+ return message || error.name || 'AggregateError';
1723
+ }
1724
+
1565
1725
  let AxiosError$1 = class AxiosError extends Error {
1566
1726
  static from(error, code, config, request, response, customProps) {
1567
- const axiosError = new AxiosError(error.message, code || error.code, config, request, response);
1727
+ // `AggregateError` (thrown by Node on dual-stack/Happy-Eyeballs connection
1728
+ // failures) has an empty `message`; its detail lives in `errors[]`. Without
1729
+ // this, the wrapped error surfaces with a blank message (see #6721).
1730
+ let message = error.message;
1731
+ if (!message && utils$1.isArray(error.errors) && error.errors.length) {
1732
+ message = aggregateErrorMessage(error);
1733
+ }
1734
+
1735
+ const axiosError = new AxiosError(message, code || error.code, config, request, response);
1568
1736
  // Match native `Error` `cause` semantics: non-enumerable. The wrapped
1569
1737
  // error often carries circular internals (sockets, requests, agents), so
1570
1738
  // an enumerable `cause` makes structured loggers (pino/winston) and any
@@ -1819,9 +1987,6 @@ function toFormData$1(obj, formData, options) {
1819
1987
  if (useBlob && typeof _Blob === 'function') {
1820
1988
  return new _Blob([value]);
1821
1989
  }
1822
- if (typeof Buffer !== 'undefined') {
1823
- return Buffer.from(value);
1824
- }
1825
1990
  throw new AxiosError$1('Blob is not supported. Use a Buffer instead.', AxiosError$1.ERR_NOT_SUPPORT);
1826
1991
  }
1827
1992
 
@@ -2258,12 +2423,18 @@ function throwIfDepthExceeded(index) {
2258
2423
  * @returns An array of strings.
2259
2424
  */
2260
2425
  function parsePropPath(name) {
2261
- // foo[x][y][z]
2262
- // foo.x.y.z
2263
- // foo-x-y-z
2264
- // foo x y z
2426
+ // foo[x][y][z] -> ['foo', 'x', 'y', 'z']
2427
+ // foo.x.y.z -> ['foo', 'x', 'y', 'z']
2428
+ // A path is split on `.` and on `[...]` groups. A segment — whether written
2429
+ // in dot notation or captured inside brackets — may contain any character
2430
+ // except `.`, `[` and `]`, so a key like `user-name` or `user name` is kept
2431
+ // literal instead of being split (#5402). `.`, `[` and `]` keep their existing
2432
+ // meaning, e.g. `foo[bar.baz]` -> ['foo', 'bar', 'baz'] and `[]` is an array push.
2433
+ // Excluding `[` from the bracket group also makes the match fail fast at the
2434
+ // next `[`, so a malformed name cannot rescan to the end of the string from
2435
+ // every unmatched `[` — parsing stays linear in the length of the name.
2265
2436
  const path = [];
2266
- const pattern = /\w+|\[(\w*)]/g;
2437
+ const pattern = /[^.[\]]+|\[([^.[\]]*)]/g;
2267
2438
  let match;
2268
2439
 
2269
2440
  while ((match = pattern.exec(name)) !== null) {
@@ -2695,7 +2866,7 @@ const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
2695
2866
  }
2696
2867
  const rawLoaded = e.loaded;
2697
2868
  const total = e.lengthComputable ? e.total : undefined;
2698
- const loaded = total != null ? Math.min(rawLoaded, total) : rawLoaded;
2869
+ const loaded = Math.max(0, total != null ? Math.min(rawLoaded, total) : rawLoaded);
2699
2870
  const progressBytes = Math.max(0, loaded - bytesNotified);
2700
2871
  const rate = _speedometer(progressBytes);
2701
2872
 
@@ -2732,9 +2903,9 @@ const progressEventDecorator = (total, throttled) => {
2732
2903
  };
2733
2904
 
2734
2905
  const asyncDecorator =
2735
- (fn) =>
2906
+ (fn, scheduler = utils$1.asap) =>
2736
2907
  (...args) =>
2737
- utils$1.asap(() => fn(...args));
2908
+ scheduler(() => fn(...args));
2738
2909
 
2739
2910
  var isURLSameOrigin = platform.hasStandardBrowserEnv
2740
2911
  ? ((origin, isMSIE) => (url) => {
@@ -2840,9 +3011,17 @@ function isAbsoluteURL(url) {
2840
3011
  * @returns {string} The combined URL
2841
3012
  */
2842
3013
  function combineURLs(baseURL, relativeURL) {
2843
- return relativeURL
2844
- ? baseURL.replace(/\/?\/$/, '') + '/' + relativeURL.replace(/^\/+/, '')
2845
- : baseURL;
3014
+ if (!relativeURL) {
3015
+ return baseURL;
3016
+ }
3017
+
3018
+ let end = baseURL.length;
3019
+
3020
+ while (end > 0 && baseURL.charCodeAt(end - 1) === 47) {
3021
+ end--;
3022
+ }
3023
+
3024
+ return baseURL.slice(0, end) + '/' + relativeURL.replace(/^\/+/, '');
2846
3025
  }
2847
3026
 
2848
3027
  const malformedHttpProtocol = /^https?:(?!\/\/)/i;
@@ -2860,13 +3039,51 @@ function normalizeURLForProtocolCheck(url) {
2860
3039
  return stripLeadingC0ControlOrSpace(url).replace(httpProtocolControlCharacters, '');
2861
3040
  }
2862
3041
 
3042
+ // Redact the parts of a URL that can carry secrets before it is embedded in an
3043
+ // error message. AxiosError.toJSON() serializes `message` verbatim and errors
3044
+ // are commonly logged, while the opt-in `config.redact` model only cleans
3045
+ // config keys — it cannot reach the message. Redact only the genuinely
3046
+ // sensitive substrings — userinfo (credentials), query parameter values and
3047
+ // fragment contents — with the same REDACTED marker the config redaction uses,
3048
+ // while keeping the scheme, host, path and parameter names so the offending
3049
+ // request stays accurately identifiable.
3050
+ function redactFragment(fragment) {
3051
+ if (!fragment) {
3052
+ return fragment;
3053
+ }
3054
+
3055
+ return fragment.replace(/(^|&)([^=&]*=)?[^&]+/g, (match, separator, parameterName = '') => {
3056
+ return `${separator}${parameterName}${REDACTED}`;
3057
+ });
3058
+ }
3059
+
3060
+ function redactSensitiveURLParts(url) {
3061
+ const redactedURL = url.replace(/^(https?:\/{0,2})[^/?#]*@/i, `$1${REDACTED}@`);
3062
+ const fragmentIndex = redactedURL.indexOf('#');
3063
+ const urlWithoutFragment =
3064
+ fragmentIndex === -1 ? redactedURL : redactedURL.slice(0, fragmentIndex);
3065
+ const redactedURLWithoutFragment = urlWithoutFragment.replace(
3066
+ /([?&][^=&#]*=)[^&#]*/g,
3067
+ `$1${REDACTED}`
3068
+ );
3069
+
3070
+ if (fragmentIndex === -1) {
3071
+ return redactedURLWithoutFragment;
3072
+ }
3073
+
3074
+ return `${redactedURLWithoutFragment}#${redactFragment(redactedURL.slice(fragmentIndex + 1))}`;
3075
+ }
3076
+
2863
3077
  function assertValidHttpProtocolURL(url, config) {
2864
- if (typeof url === 'string' && malformedHttpProtocol.test(normalizeURLForProtocolCheck(url))) {
2865
- throw new AxiosError$1(
2866
- 'Invalid URL: missing "//" after protocol',
2867
- AxiosError$1.ERR_INVALID_URL,
2868
- config
2869
- );
3078
+ if (typeof url === 'string') {
3079
+ const normalizedURL = normalizeURLForProtocolCheck(url);
3080
+ if (malformedHttpProtocol.test(normalizedURL)) {
3081
+ throw new AxiosError$1(
3082
+ `Invalid URL ${JSON.stringify(redactSensitiveURLParts(normalizedURL))}: missing "//" after protocol`,
3083
+ AxiosError$1.ERR_INVALID_URL,
3084
+ config
3085
+ );
3086
+ }
2870
3087
  }
2871
3088
  }
2872
3089
 
@@ -2892,6 +3109,17 @@ function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls, config) {
2892
3109
 
2893
3110
  const headersToObject = (thing) => (thing instanceof AxiosHeaders$1 ? { ...thing } : thing);
2894
3111
 
3112
+ const ownEnumerableKeys = (thing) => {
3113
+ if (Object.getOwnPropertySymbols && Object.getOwnPropertyDescriptor) {
3114
+ return Object.keys(thing).concat(
3115
+ Object.getOwnPropertySymbols(thing).filter(
3116
+ (symbol) => Object.getOwnPropertyDescriptor(thing, symbol).enumerable
3117
+ )
3118
+ );
3119
+ }
3120
+ return Object.keys(thing);
3121
+ };
3122
+
2895
3123
  /**
2896
3124
  * Config-specific merge-function which creates a new config-object
2897
3125
  * by merging two configuration objects together.
@@ -2957,7 +3185,9 @@ function mergeConfig$1(config1, config2) {
2957
3185
  }
2958
3186
 
2959
3187
  function getMergedTransitionalOption(prop) {
2960
- const transitional2 = utils$1.hasOwnProp(config2, 'transitional') ? config2.transitional : undefined;
3188
+ const transitional2 = utils$1.hasOwnProp(config2, 'transitional')
3189
+ ? config2.transitional
3190
+ : undefined;
2961
3191
 
2962
3192
  if (!utils$1.isUndefined(transitional2)) {
2963
3193
  if (utils$1.isPlainObject(transitional2)) {
@@ -2969,7 +3199,9 @@ function mergeConfig$1(config1, config2) {
2969
3199
  }
2970
3200
  }
2971
3201
 
2972
- const transitional1 = utils$1.hasOwnProp(config1, 'transitional') ? config1.transitional : undefined;
3202
+ const transitional1 = utils$1.hasOwnProp(config1, 'transitional')
3203
+ ? config1.transitional
3204
+ : undefined;
2973
3205
 
2974
3206
  if (utils$1.isPlainObject(transitional1) && utils$1.hasOwnProp(transitional1, prop)) {
2975
3207
  return transitional1[prop];
@@ -3021,7 +3253,7 @@ function mergeConfig$1(config1, config2) {
3021
3253
  mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true),
3022
3254
  };
3023
3255
 
3024
- utils$1.forEach(Object.keys({ ...config1, ...config2 }), function computeConfigValue(prop) {
3256
+ utils$1.forEach(ownEnumerableKeys({ ...config1, ...config2 }), function computeConfigValue(prop) {
3025
3257
  if (prop === '__proto__' || prop === 'constructor' || prop === 'prototype') return;
3026
3258
  const merge = utils$1.hasOwnProp(mergeMap, prop) ? mergeMap[prop] : mergeDeepProperties;
3027
3259
  const a = utils$1.hasOwnProp(config1, prop) ? config1[prop] : undefined;
@@ -3047,6 +3279,17 @@ function mergeConfig$1(config1, config2) {
3047
3279
 
3048
3280
  const FORM_DATA_CONTENT_HEADERS = ['content-type', 'content-length'];
3049
3281
 
3282
+ /**
3283
+ * Apply the headers generated by a FormData implementation to the request headers,
3284
+ * honoring the `formDataHeaderPolicy` option: with 'content-only', copy only the
3285
+ * content-* headers; otherwise merge all of them.
3286
+ *
3287
+ * @param {AxiosHeaders} headers - the request headers to mutate
3288
+ * @param {Object | null | undefined} formHeaders - headers produced by the FormData implementation
3289
+ * @param {String} [policy] - the resolved `formDataHeaderPolicy` config value
3290
+ *
3291
+ * @returns {void}
3292
+ */
3050
3293
  function setFormDataHeaders(headers, formHeaders, policy) {
3051
3294
  if (policy !== 'content-only') {
3052
3295
  headers.set(formHeaders);
@@ -3413,7 +3656,18 @@ const composeSignals = (signals, timeout) => {
3413
3656
  signals = null;
3414
3657
  };
3415
3658
 
3416
- signals.forEach((signal) => signal.addEventListener('abort', onabort, { once: true }));
3659
+ signals.forEach((signal) => {
3660
+ if (aborted) {
3661
+ return;
3662
+ }
3663
+
3664
+ if (signal.aborted) {
3665
+ onabort.call(signal);
3666
+ return;
3667
+ }
3668
+
3669
+ signal.addEventListener('abort', onabort, { once: true });
3670
+ });
3417
3671
 
3418
3672
  const { signal } = controller;
3419
3673
 
@@ -3513,13 +3767,11 @@ const trackStream = (stream, chunkSize, onProgress, onFinish) => {
3513
3767
  };
3514
3768
 
3515
3769
  /**
3516
- * Estimate decoded byte length of a data:// URL *without* allocating large buffers.
3517
- * - For base64: compute exact decoded size using length and padding;
3518
- * handle %XX at the character-count level (no string allocation).
3519
- * - For non-base64: compute the exact percent-decoded UTF-8 byte length.
3520
- *
3521
- * @param {string} url
3522
- * @returns {number}
3770
+ * Estimate data: URL byte lengths *without* allocating large buffers.
3771
+ * - Fetch percent-decodes a base64 body before decoding it.
3772
+ * - Node's Buffer.from(body, 'base64') sizes its backing allocation from the
3773
+ * raw body, including ignored characters and content after padding.
3774
+ * - Non-base64 data is percent-decoded and then encoded as UTF-8.
3523
3775
  */
3524
3776
  const isHexDigit = (charCode) =>
3525
3777
  (charCode >= 48 && charCode <= 57) ||
@@ -3529,7 +3781,89 @@ const isHexDigit = (charCode) =>
3529
3781
  const isPercentEncodedByte = (str, i, len) =>
3530
3782
  i + 2 < len && isHexDigit(str.charCodeAt(i + 1)) && isHexDigit(str.charCodeAt(i + 2));
3531
3783
 
3532
- function estimateDataURLDecodedBytes(url) {
3784
+ const hexValue = (charCode) => (charCode <= 57 ? charCode - 48 : (charCode & 0xdf) - 55);
3785
+
3786
+ const isBase64Char = (charCode) =>
3787
+ (charCode >= 65 && charCode <= 90) || // A-Z
3788
+ (charCode >= 97 && charCode <= 122) || // a-z
3789
+ (charCode >= 48 && charCode <= 57) || // 0-9
3790
+ charCode === 43 || // +
3791
+ charCode === 47 || // /
3792
+ charCode === 45 || // - (base64url)
3793
+ charCode === 95; // _ (base64url)
3794
+
3795
+ const isBase64Whitespace = (charCode) =>
3796
+ charCode === 9 || charCode === 10 || charCode === 12 || charCode === 13 || charCode === 32;
3797
+
3798
+ const base64Bytes = (significant) => {
3799
+ const groups = Math.floor(significant / 4);
3800
+ const remainder = significant % 4;
3801
+ return groups * 3 + (remainder === 2 ? 1 : remainder === 3 ? 2 : 0);
3802
+ };
3803
+
3804
+ // Buffer.byteLength(body, 'base64') uses the raw string length as an allocation
3805
+ // upper bound even when Buffer.from later ignores characters or stops at '='.
3806
+ const estimateBase64BufferAllocation = (body) => {
3807
+ const len = body.length;
3808
+ let padding = 0;
3809
+
3810
+ if (len > 0 && body.charCodeAt(len - 1) === 61 /* '=' */) {
3811
+ padding++;
3812
+
3813
+ if (len > 1 && body.charCodeAt(len - 2) === 61 /* '=' */) {
3814
+ padding++;
3815
+ }
3816
+ }
3817
+
3818
+ return Math.floor(((len - padding) * 3) / 4);
3819
+ };
3820
+
3821
+ const estimatePercentDecodedBase64Bytes = (body) => {
3822
+ const len = body.length;
3823
+ let significant = 0;
3824
+ let padding = 0;
3825
+ let invalid = false;
3826
+
3827
+ for (let i = 0; i < len; i++) {
3828
+ let code = body.charCodeAt(i);
3829
+
3830
+ if (code === 37 /* '%' */ && isPercentEncodedByte(body, i, len)) {
3831
+ code = hexValue(body.charCodeAt(i + 1)) * 16 + hexValue(body.charCodeAt(i + 2));
3832
+ i += 2;
3833
+ }
3834
+
3835
+ if (isBase64Whitespace(code)) {
3836
+ continue;
3837
+ }
3838
+
3839
+ if (code === 61 /* '=' */) {
3840
+ padding++;
3841
+ continue;
3842
+ }
3843
+
3844
+ if (!isBase64Char(code) || padding > 0) {
3845
+ invalid = true;
3846
+ continue;
3847
+ }
3848
+
3849
+ significant++;
3850
+ }
3851
+
3852
+ // Fetch rejects malformed forgiving-base64 input. Returning the raw-size
3853
+ // allocation bound keeps that invalid input from becoming a pre-check bypass.
3854
+ if (
3855
+ invalid ||
3856
+ padding > 2 ||
3857
+ (padding > 0 && (significant + padding) % 4 !== 0) ||
3858
+ significant % 4 === 1
3859
+ ) {
3860
+ return estimateBase64BufferAllocation(body);
3861
+ }
3862
+
3863
+ return base64Bytes(significant);
3864
+ };
3865
+
3866
+ const estimateDataURLBytes = (url, estimateBase64) => {
3533
3867
  if (!url || typeof url !== 'string') return 0;
3534
3868
  if (!url.startsWith('data:')) return 0;
3535
3869
 
@@ -3541,52 +3875,7 @@ function estimateDataURLDecodedBytes(url) {
3541
3875
  const isBase64 = /;base64/i.test(meta);
3542
3876
 
3543
3877
  if (isBase64) {
3544
- let effectiveLen = body.length;
3545
- const len = body.length; // cache length
3546
-
3547
- for (let i = 0; i < len; i++) {
3548
- if (body.charCodeAt(i) === 37 /* '%' */ && i + 2 < len) {
3549
- const a = body.charCodeAt(i + 1);
3550
- const b = body.charCodeAt(i + 2);
3551
- const isHex = isHexDigit(a) && isHexDigit(b);
3552
-
3553
- if (isHex) {
3554
- effectiveLen -= 2;
3555
- i += 2;
3556
- }
3557
- }
3558
- }
3559
-
3560
- let pad = 0;
3561
- let idx = len - 1;
3562
-
3563
- const tailIsPct3D = (j) =>
3564
- j >= 2 &&
3565
- body.charCodeAt(j - 2) === 37 && // '%'
3566
- body.charCodeAt(j - 1) === 51 && // '3'
3567
- (body.charCodeAt(j) === 68 || body.charCodeAt(j) === 100); // 'D' or 'd'
3568
-
3569
- if (idx >= 0) {
3570
- if (body.charCodeAt(idx) === 61 /* '=' */) {
3571
- pad++;
3572
- idx--;
3573
- } else if (tailIsPct3D(idx)) {
3574
- pad++;
3575
- idx -= 3;
3576
- }
3577
- }
3578
-
3579
- if (pad === 1 && idx >= 0) {
3580
- if (body.charCodeAt(idx) === 61 /* '=' */) {
3581
- pad++;
3582
- } else if (tailIsPct3D(idx)) {
3583
- pad++;
3584
- }
3585
- }
3586
-
3587
- const groups = Math.floor(effectiveLen / 4);
3588
- const bytes = groups * 3 - (pad || 0);
3589
- return bytes > 0 ? bytes : 0;
3878
+ return estimateBase64(body);
3590
3879
  }
3591
3880
 
3592
3881
  // Compute UTF-8 byte length directly from UTF-16 code units without allocating
@@ -3616,9 +3905,25 @@ function estimateDataURLDecodedBytes(url) {
3616
3905
  }
3617
3906
  }
3618
3907
  return bytes;
3908
+ };
3909
+
3910
+ /**
3911
+ * Estimate the percent-decoded payload size used by Fetch data: URLs.
3912
+ *
3913
+ * @param {string} url
3914
+ * @returns {number}
3915
+ */
3916
+ function estimateDataURLDecodedBytes(url) {
3917
+ // Fetch removes URL fragments before processing a data: URL.
3918
+ const fragmentIndex = typeof url === 'string' ? url.indexOf('#') : -1;
3919
+
3920
+ return estimateDataURLBytes(
3921
+ fragmentIndex === -1 ? url : url.slice(0, fragmentIndex),
3922
+ estimatePercentDecodedBase64Bytes
3923
+ );
3619
3924
  }
3620
3925
 
3621
- const VERSION$1 = "1.18.1";
3926
+ const VERSION$1 = "1.19.0";
3622
3927
 
3623
3928
  const DEFAULT_CHUNK_SIZE = 64 * 1024;
3624
3929
 
@@ -4758,17 +5063,35 @@ let Axios$1 = class Axios {
4758
5063
  const onFulfilled = requestInterceptorChain[i++];
4759
5064
  const onRejected = requestInterceptorChain[i++];
4760
5065
  try {
4761
- newConfig = onFulfilled(newConfig);
5066
+ newConfig = onFulfilled ? onFulfilled(newConfig) : newConfig;
4762
5067
  } catch (error) {
4763
- onRejected.call(this, error);
5068
+ if (!onRejected) {
5069
+ promise = Promise.reject(error);
5070
+ break;
5071
+ }
5072
+
5073
+ try {
5074
+ const rejectedResult = onRejected.call(this, error);
5075
+
5076
+ if (utils$1.isThenable(rejectedResult)) {
5077
+ promise = Promise.resolve(rejectedResult).then(() =>
5078
+ dispatchRequest.call(this, newConfig)
5079
+ );
5080
+ }
5081
+ } catch (rejectedError) {
5082
+ promise = Promise.reject(rejectedError);
5083
+ }
5084
+
4764
5085
  break;
4765
5086
  }
4766
5087
  }
4767
5088
 
4768
- try {
4769
- promise = dispatchRequest.call(this, newConfig);
4770
- } catch (error) {
4771
- return Promise.reject(error);
5089
+ if (!promise) {
5090
+ try {
5091
+ promise = dispatchRequest.call(this, newConfig);
5092
+ } catch (error) {
5093
+ promise = Promise.reject(error);
5094
+ }
4772
5095
  }
4773
5096
 
4774
5097
  i = 0;
@@ -5061,6 +5384,7 @@ const HttpStatusCode$1 = {
5061
5384
  LoopDetected: 508,
5062
5385
  NotExtended: 510,
5063
5386
  NetworkAuthenticationRequired: 511,
5387
+ WebServerReturnsAnUnknownError: 520,
5064
5388
  WebServerIsDown: 521,
5065
5389
  ConnectionTimedOut: 522,
5066
5390
  OriginIsUnreachable: 523,
@@ -5164,4 +5488,3 @@ const {
5164
5488
  } = axios;
5165
5489
 
5166
5490
  export { Axios, AxiosError, AxiosHeaders, Cancel, CancelToken, CanceledError, HttpStatusCode, VERSION, all, create, axios as default, formToJSON, getAdapter, isAxiosError, isCancel, mergeConfig, spread, toFormData };
5167
- //# sourceMappingURL=axios.js.map