axios 1.13.2 → 1.13.3

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.
@@ -1,4 +1,4 @@
1
- /*! Axios v1.13.2 Copyright (c) 2025 Matt Zabriskie and contributors */
1
+ /*! Axios v1.13.3 Copyright (c) 2026 Matt Zabriskie and contributors */
2
2
  'use strict';
3
3
 
4
4
  const FormData$1 = require('form-data');
@@ -291,10 +291,11 @@ const trim = (str) => str.trim ?
291
291
  * If 'obj' is an Object callback will be called passing
292
292
  * the value, key, and complete object for each property.
293
293
  *
294
- * @param {Object|Array} obj The object to iterate
294
+ * @param {Object|Array<unknown>} obj The object to iterate
295
295
  * @param {Function} fn The callback to invoke for each item
296
296
  *
297
- * @param {Boolean} [allOwnKeys = false]
297
+ * @param {Object} [options]
298
+ * @param {Boolean} [options.allOwnKeys = false]
298
299
  * @returns {any}
299
300
  */
300
301
  function forEach(obj, fn, {allOwnKeys = false} = {}) {
@@ -371,7 +372,7 @@ const isContextDefined = (context) => !isUndefined(context) && context !== _glob
371
372
  * Example:
372
373
  *
373
374
  * ```js
374
- * var result = merge({foo: 123}, {foo: 456});
375
+ * const result = merge({foo: 123}, {foo: 456});
375
376
  * console.log(result.foo); // outputs 456
376
377
  * ```
377
378
  *
@@ -408,15 +409,26 @@ function merge(/* obj1, obj2, obj3, ... */) {
408
409
  * @param {Object} b The object to copy properties from
409
410
  * @param {Object} thisArg The object to bind function to
410
411
  *
411
- * @param {Boolean} [allOwnKeys]
412
+ * @param {Object} [options]
413
+ * @param {Boolean} [options.allOwnKeys]
412
414
  * @returns {Object} The resulting value of object a
413
415
  */
414
416
  const extend = (a, b, thisArg, {allOwnKeys}= {}) => {
415
417
  forEach(b, (val, key) => {
416
418
  if (thisArg && isFunction$1(val)) {
417
- a[key] = bind(val, thisArg);
419
+ Object.defineProperty(a, key, {
420
+ value: bind(val, thisArg),
421
+ writable: true,
422
+ enumerable: true,
423
+ configurable: true
424
+ });
418
425
  } else {
419
- a[key] = val;
426
+ Object.defineProperty(a, key, {
427
+ value: val,
428
+ writable: true,
429
+ enumerable: true,
430
+ configurable: true
431
+ });
420
432
  }
421
433
  }, {allOwnKeys});
422
434
  return a;
@@ -447,7 +459,12 @@ const stripBOM = (content) => {
447
459
  */
448
460
  const inherits = (constructor, superConstructor, props, descriptors) => {
449
461
  constructor.prototype = Object.create(superConstructor.prototype, descriptors);
450
- constructor.prototype.constructor = constructor;
462
+ Object.defineProperty(constructor.prototype, 'constructor', {
463
+ value: constructor,
464
+ writable: true,
465
+ enumerable: false,
466
+ configurable: true
467
+ });
451
468
  Object.defineProperty(constructor, 'super', {
452
469
  value: superConstructor.prototype
453
470
  });
@@ -820,110 +837,75 @@ const utils$1 = {
820
837
  isIterable
821
838
  };
822
839
 
823
- /**
824
- * Create an Error with the specified message, config, error code, request and response.
825
- *
826
- * @param {string} message The error message.
827
- * @param {string} [code] The error code (for example, 'ECONNABORTED').
828
- * @param {Object} [config] The config.
829
- * @param {Object} [request] The request.
830
- * @param {Object} [response] The response.
831
- *
832
- * @returns {Error} The created error.
833
- */
834
- function AxiosError(message, code, config, request, response) {
835
- Error.call(this);
836
-
837
- if (Error.captureStackTrace) {
838
- Error.captureStackTrace(this, this.constructor);
839
- } else {
840
- this.stack = (new Error()).stack;
841
- }
840
+ class AxiosError extends Error {
841
+ static from(error, code, config, request, response, customProps) {
842
+ const axiosError = new AxiosError(error.message, code || error.code, config, request, response);
843
+ axiosError.cause = error;
844
+ axiosError.name = error.name;
845
+ customProps && Object.assign(axiosError, customProps);
846
+ return axiosError;
847
+ }
848
+
849
+ /**
850
+ * Create an Error with the specified message, config, error code, request and response.
851
+ *
852
+ * @param {string} message The error message.
853
+ * @param {string} [code] The error code (for example, 'ECONNABORTED').
854
+ * @param {Object} [config] The config.
855
+ * @param {Object} [request] The request.
856
+ * @param {Object} [response] The response.
857
+ *
858
+ * @returns {Error} The created error.
859
+ */
860
+ constructor(message, code, config, request, response) {
861
+ super(message);
862
+ this.name = 'AxiosError';
863
+ this.isAxiosError = true;
864
+ code && (this.code = code);
865
+ config && (this.config = config);
866
+ request && (this.request = request);
867
+ if (response) {
868
+ this.response = response;
869
+ this.status = response.status;
870
+ }
871
+ }
842
872
 
843
- this.message = message;
844
- this.name = 'AxiosError';
845
- code && (this.code = code);
846
- config && (this.config = config);
847
- request && (this.request = request);
848
- if (response) {
849
- this.response = response;
850
- this.status = response.status ? response.status : null;
851
- }
873
+ toJSON() {
874
+ return {
875
+ // Standard
876
+ message: this.message,
877
+ name: this.name,
878
+ // Microsoft
879
+ description: this.description,
880
+ number: this.number,
881
+ // Mozilla
882
+ fileName: this.fileName,
883
+ lineNumber: this.lineNumber,
884
+ columnNumber: this.columnNumber,
885
+ stack: this.stack,
886
+ // Axios
887
+ config: utils$1.toJSONObject(this.config),
888
+ code: this.code,
889
+ status: this.status,
890
+ };
891
+ }
852
892
  }
853
893
 
854
- utils$1.inherits(AxiosError, Error, {
855
- toJSON: function toJSON() {
856
- return {
857
- // Standard
858
- message: this.message,
859
- name: this.name,
860
- // Microsoft
861
- description: this.description,
862
- number: this.number,
863
- // Mozilla
864
- fileName: this.fileName,
865
- lineNumber: this.lineNumber,
866
- columnNumber: this.columnNumber,
867
- stack: this.stack,
868
- // Axios
869
- config: utils$1.toJSONObject(this.config),
870
- code: this.code,
871
- status: this.status
872
- };
873
- }
874
- });
875
-
876
- const prototype$1 = AxiosError.prototype;
877
- const descriptors = {};
878
-
879
- [
880
- 'ERR_BAD_OPTION_VALUE',
881
- 'ERR_BAD_OPTION',
882
- 'ECONNABORTED',
883
- 'ETIMEDOUT',
884
- 'ERR_NETWORK',
885
- 'ERR_FR_TOO_MANY_REDIRECTS',
886
- 'ERR_DEPRECATED',
887
- 'ERR_BAD_RESPONSE',
888
- 'ERR_BAD_REQUEST',
889
- 'ERR_CANCELED',
890
- 'ERR_NOT_SUPPORT',
891
- 'ERR_INVALID_URL'
892
- // eslint-disable-next-line func-names
893
- ].forEach(code => {
894
- descriptors[code] = {value: code};
895
- });
896
-
897
- Object.defineProperties(AxiosError, descriptors);
898
- Object.defineProperty(prototype$1, 'isAxiosError', {value: true});
899
-
900
- // eslint-disable-next-line func-names
901
- AxiosError.from = (error, code, config, request, response, customProps) => {
902
- const axiosError = Object.create(prototype$1);
903
-
904
- utils$1.toFlatObject(error, axiosError, function filter(obj) {
905
- return obj !== Error.prototype;
906
- }, prop => {
907
- return prop !== 'isAxiosError';
908
- });
909
-
910
- const msg = error && error.message ? error.message : 'Error';
911
-
912
- // Prefer explicit code; otherwise copy the low-level error's code (e.g. ECONNREFUSED)
913
- const errCode = code == null && error ? error.code : code;
914
- AxiosError.call(axiosError, msg, errCode, config, request, response);
915
-
916
- // Chain the original error on the standard field; non-enumerable to avoid JSON noise
917
- if (error && axiosError.cause == null) {
918
- Object.defineProperty(axiosError, 'cause', { value: error, configurable: true });
919
- }
920
-
921
- axiosError.name = (error && error.name) || 'Error';
922
-
923
- customProps && Object.assign(axiosError, customProps);
924
-
925
- return axiosError;
926
- };
894
+ // This can be changed to static properties as soon as the parser options in .eslint.cjs are updated.
895
+ AxiosError.ERR_BAD_OPTION_VALUE = 'ERR_BAD_OPTION_VALUE';
896
+ AxiosError.ERR_BAD_OPTION = 'ERR_BAD_OPTION';
897
+ AxiosError.ECONNABORTED = 'ECONNABORTED';
898
+ AxiosError.ETIMEDOUT = 'ETIMEDOUT';
899
+ AxiosError.ERR_NETWORK = 'ERR_NETWORK';
900
+ AxiosError.ERR_FR_TOO_MANY_REDIRECTS = 'ERR_FR_TOO_MANY_REDIRECTS';
901
+ AxiosError.ERR_DEPRECATED = 'ERR_DEPRECATED';
902
+ AxiosError.ERR_BAD_RESPONSE = 'ERR_BAD_RESPONSE';
903
+ AxiosError.ERR_BAD_REQUEST = 'ERR_BAD_REQUEST';
904
+ AxiosError.ERR_CANCELED = 'ERR_CANCELED';
905
+ AxiosError.ERR_NOT_SUPPORT = 'ERR_NOT_SUPPORT';
906
+ AxiosError.ERR_INVALID_URL = 'ERR_INVALID_URL';
907
+
908
+ const AxiosError$1 = AxiosError;
927
909
 
928
910
  /**
929
911
  * Determines if the given thing is a array or js object.
@@ -1045,7 +1027,7 @@ function toFormData(obj, formData, options) {
1045
1027
  }
1046
1028
 
1047
1029
  if (!useBlob && utils$1.isBlob(value)) {
1048
- throw new AxiosError('Blob is not supported. Use a Buffer instead.');
1030
+ throw new AxiosError$1('Blob is not supported. Use a Buffer instead.');
1049
1031
  }
1050
1032
 
1051
1033
  if (utils$1.isArrayBuffer(value) || utils$1.isTypedArray(value)) {
@@ -1219,29 +1201,26 @@ function encode(val) {
1219
1201
  * @returns {string} The formatted url
1220
1202
  */
1221
1203
  function buildURL(url, params, options) {
1222
- /*eslint no-param-reassign:0*/
1223
1204
  if (!params) {
1224
1205
  return url;
1225
1206
  }
1226
-
1207
+
1227
1208
  const _encode = options && options.encode || encode;
1228
1209
 
1229
- if (utils$1.isFunction(options)) {
1230
- options = {
1231
- serialize: options
1232
- };
1233
- }
1210
+ const _options = utils$1.isFunction(options) ? {
1211
+ serialize: options
1212
+ } : options;
1234
1213
 
1235
- const serializeFn = options && options.serialize;
1214
+ const serializeFn = _options && _options.serialize;
1236
1215
 
1237
1216
  let serializedParams;
1238
1217
 
1239
1218
  if (serializeFn) {
1240
- serializedParams = serializeFn(params, options);
1219
+ serializedParams = serializeFn(params, _options);
1241
1220
  } else {
1242
1221
  serializedParams = utils$1.isURLSearchParams(params) ?
1243
1222
  params.toString() :
1244
- new AxiosURLSearchParams(params, options).toString(_encode);
1223
+ new AxiosURLSearchParams(params, _options).toString(_encode);
1245
1224
  }
1246
1225
 
1247
1226
  if (serializedParams) {
@@ -1266,6 +1245,7 @@ class InterceptorManager {
1266
1245
  *
1267
1246
  * @param {Function} fulfilled The function to handle `then` for a `Promise`
1268
1247
  * @param {Function} rejected The function to handle `reject` for a `Promise`
1248
+ * @param {Object} options The options for the interceptor, synchronous and runWhen
1269
1249
  *
1270
1250
  * @return {Number} An ID used to remove interceptor later
1271
1251
  */
@@ -1636,7 +1616,7 @@ const defaults = {
1636
1616
  } catch (e) {
1637
1617
  if (strictJSONParsing) {
1638
1618
  if (e.name === 'SyntaxError') {
1639
- throw AxiosError.from(e, AxiosError.ERR_BAD_RESPONSE, this, null, this.response);
1619
+ throw AxiosError$1.from(e, AxiosError$1.ERR_BAD_RESPONSE, this, null, this.response);
1640
1620
  }
1641
1621
  throw e;
1642
1622
  }
@@ -2070,24 +2050,24 @@ function isCancel(value) {
2070
2050
  return !!(value && value.__CANCEL__);
2071
2051
  }
2072
2052
 
2073
- /**
2074
- * A `CanceledError` is an object that is thrown when an operation is canceled.
2075
- *
2076
- * @param {string=} message The message.
2077
- * @param {Object=} config The config.
2078
- * @param {Object=} request The request.
2079
- *
2080
- * @returns {CanceledError} The created error.
2081
- */
2082
- function CanceledError(message, config, request) {
2083
- // eslint-disable-next-line no-eq-null,eqeqeq
2084
- AxiosError.call(this, message == null ? 'canceled' : message, AxiosError.ERR_CANCELED, config, request);
2085
- this.name = 'CanceledError';
2053
+ class CanceledError extends AxiosError$1 {
2054
+ /**
2055
+ * A `CanceledError` is an object that is thrown when an operation is canceled.
2056
+ *
2057
+ * @param {string=} message The message.
2058
+ * @param {Object=} config The config.
2059
+ * @param {Object=} request The request.
2060
+ *
2061
+ * @returns {CanceledError} The created error.
2062
+ */
2063
+ constructor(message, config, request) {
2064
+ super(message == null ? 'canceled' : message, AxiosError$1.ERR_CANCELED, config, request);
2065
+ this.name = 'CanceledError';
2066
+ this.__CANCEL__ = true;
2067
+ }
2086
2068
  }
2087
2069
 
2088
- utils$1.inherits(CanceledError, AxiosError, {
2089
- __CANCEL__: true
2090
- });
2070
+ const CanceledError$1 = CanceledError;
2091
2071
 
2092
2072
  /**
2093
2073
  * Resolve or reject a Promise based on response status.
@@ -2103,9 +2083,9 @@ function settle(resolve, reject, response) {
2103
2083
  if (!response.status || !validateStatus || validateStatus(response.status)) {
2104
2084
  resolve(response);
2105
2085
  } else {
2106
- reject(new AxiosError(
2086
+ reject(new AxiosError$1(
2107
2087
  'Request failed with status code ' + response.status,
2108
- [AxiosError.ERR_BAD_REQUEST, AxiosError.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
2088
+ [AxiosError$1.ERR_BAD_REQUEST, AxiosError$1.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
2109
2089
  response.config,
2110
2090
  response.request,
2111
2091
  response
@@ -2159,7 +2139,7 @@ function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls) {
2159
2139
  return requestedURL;
2160
2140
  }
2161
2141
 
2162
- const VERSION = "1.13.2";
2142
+ const VERSION = "1.13.3";
2163
2143
 
2164
2144
  function parseProtocol(url) {
2165
2145
  const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
@@ -2192,7 +2172,7 @@ function fromDataURI(uri, asBlob, options) {
2192
2172
  const match = DATA_URL_PATTERN.exec(uri);
2193
2173
 
2194
2174
  if (!match) {
2195
- throw new AxiosError('Invalid URL', AxiosError.ERR_INVALID_URL);
2175
+ throw new AxiosError$1('Invalid URL', AxiosError$1.ERR_INVALID_URL);
2196
2176
  }
2197
2177
 
2198
2178
  const mime = match[1];
@@ -2202,7 +2182,7 @@ function fromDataURI(uri, asBlob, options) {
2202
2182
 
2203
2183
  if (asBlob) {
2204
2184
  if (!_Blob) {
2205
- throw new AxiosError('Blob is not supported', AxiosError.ERR_NOT_SUPPORT);
2185
+ throw new AxiosError$1('Blob is not supported', AxiosError$1.ERR_NOT_SUPPORT);
2206
2186
  }
2207
2187
 
2208
2188
  return new _Blob([buffer], {type: mime});
@@ -2211,7 +2191,7 @@ function fromDataURI(uri, asBlob, options) {
2211
2191
  return buffer;
2212
2192
  }
2213
2193
 
2214
- throw new AxiosError('Unsupported protocol ' + protocol, AxiosError.ERR_NOT_SUPPORT);
2194
+ throw new AxiosError$1('Unsupported protocol ' + protocol, AxiosError$1.ERR_NOT_SUPPORT);
2215
2195
  }
2216
2196
 
2217
2197
  const kInternals = Symbol('internals');
@@ -2893,12 +2873,16 @@ function setProxy(options, configProxy, location) {
2893
2873
 
2894
2874
  if (proxy.auth) {
2895
2875
  // Support proxy auth object form
2896
- if (proxy.auth.username || proxy.auth.password) {
2876
+ const validProxyAuth = Boolean(proxy.auth.username || proxy.auth.password);
2877
+
2878
+ if (validProxyAuth) {
2897
2879
  proxy.auth = (proxy.auth.username || '') + ':' + (proxy.auth.password || '');
2880
+ } else if (typeof proxy.auth === 'object') {
2881
+ throw new AxiosError$1('Invalid proxy authorization', AxiosError$1.ERR_BAD_OPTION, { proxy });
2898
2882
  }
2899
- const base64 = Buffer
2900
- .from(proxy.auth, 'utf8')
2901
- .toString('base64');
2883
+
2884
+ const base64 = Buffer.from(proxy.auth, 'utf8').toString('base64');
2885
+
2902
2886
  options.headers['Proxy-Authorization'] = 'Basic ' + base64;
2903
2887
  }
2904
2888
 
@@ -2964,7 +2948,8 @@ const buildAddressEntry = (address, family) => resolveFamily(utils$1.isObject(ad
2964
2948
 
2965
2949
  const http2Transport = {
2966
2950
  request(options, cb) {
2967
- const authority = options.protocol + '//' + options.hostname + ':' + (options.port || 80);
2951
+ const authority = options.protocol + '//' + options.hostname + ':' + (options.port ||(options.protocol === 'https:' ? 443 : 80));
2952
+
2968
2953
 
2969
2954
  const {http2Options, headers} = options;
2970
2955
 
@@ -3051,7 +3036,7 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
3051
3036
 
3052
3037
  function abort(reason) {
3053
3038
  try {
3054
- abortEmitter.emit('abort', !reason || reason.type ? new CanceledError(null, config, req) : reason);
3039
+ abortEmitter.emit('abort', !reason || reason.type ? new CanceledError$1(null, config, req) : reason);
3055
3040
  } catch(err) {
3056
3041
  console.warn('emit error', err);
3057
3042
  }
@@ -3116,9 +3101,9 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
3116
3101
  const estimated = estimateDataURLDecodedBytes(dataUrl);
3117
3102
 
3118
3103
  if (estimated > config.maxContentLength) {
3119
- return reject(new AxiosError(
3104
+ return reject(new AxiosError$1(
3120
3105
  'maxContentLength size of ' + config.maxContentLength + ' exceeded',
3121
- AxiosError.ERR_BAD_RESPONSE,
3106
+ AxiosError$1.ERR_BAD_RESPONSE,
3122
3107
  config
3123
3108
  ));
3124
3109
  }
@@ -3140,7 +3125,7 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
3140
3125
  Blob: config.env && config.env.Blob
3141
3126
  });
3142
3127
  } catch (err) {
3143
- throw AxiosError.from(err, AxiosError.ERR_BAD_REQUEST, config);
3128
+ throw AxiosError$1.from(err, AxiosError$1.ERR_BAD_REQUEST, config);
3144
3129
  }
3145
3130
 
3146
3131
  if (responseType === 'text') {
@@ -3163,9 +3148,9 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
3163
3148
  }
3164
3149
 
3165
3150
  if (supportedProtocols.indexOf(protocol) === -1) {
3166
- return reject(new AxiosError(
3151
+ return reject(new AxiosError$1(
3167
3152
  'Unsupported protocol ' + protocol,
3168
- AxiosError.ERR_BAD_REQUEST,
3153
+ AxiosError$1.ERR_BAD_REQUEST,
3169
3154
  config
3170
3155
  ));
3171
3156
  }
@@ -3215,9 +3200,9 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
3215
3200
  } else if (utils$1.isString(data)) {
3216
3201
  data = Buffer.from(data, 'utf-8');
3217
3202
  } else {
3218
- return reject(new AxiosError(
3203
+ return reject(new AxiosError$1(
3219
3204
  'Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream',
3220
- AxiosError.ERR_BAD_REQUEST,
3205
+ AxiosError$1.ERR_BAD_REQUEST,
3221
3206
  config
3222
3207
  ));
3223
3208
  }
@@ -3226,9 +3211,9 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
3226
3211
  headers.setContentLength(data.length, false);
3227
3212
 
3228
3213
  if (config.maxBodyLength > -1 && data.length > config.maxBodyLength) {
3229
- return reject(new AxiosError(
3214
+ return reject(new AxiosError$1(
3230
3215
  'Request body larger than maxBodyLength limit',
3231
- AxiosError.ERR_BAD_REQUEST,
3216
+ AxiosError$1.ERR_BAD_REQUEST,
3232
3217
  config
3233
3218
  ));
3234
3219
  }
@@ -3450,8 +3435,8 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
3450
3435
  // stream.destroy() emit aborted event before calling reject() on Node.js v16
3451
3436
  rejected = true;
3452
3437
  responseStream.destroy();
3453
- abort(new AxiosError('maxContentLength size of ' + config.maxContentLength + ' exceeded',
3454
- AxiosError.ERR_BAD_RESPONSE, config, lastRequest));
3438
+ abort(new AxiosError$1('maxContentLength size of ' + config.maxContentLength + ' exceeded',
3439
+ AxiosError$1.ERR_BAD_RESPONSE, config, lastRequest));
3455
3440
  }
3456
3441
  });
3457
3442
 
@@ -3460,9 +3445,9 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
3460
3445
  return;
3461
3446
  }
3462
3447
 
3463
- const err = new AxiosError(
3448
+ const err = new AxiosError$1(
3464
3449
  'stream has been aborted',
3465
- AxiosError.ERR_BAD_RESPONSE,
3450
+ AxiosError$1.ERR_BAD_RESPONSE,
3466
3451
  config,
3467
3452
  lastRequest
3468
3453
  );
@@ -3472,7 +3457,7 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
3472
3457
 
3473
3458
  responseStream.on('error', function handleStreamError(err) {
3474
3459
  if (req.destroyed) return;
3475
- reject(AxiosError.from(err, null, config, lastRequest));
3460
+ reject(AxiosError$1.from(err, null, config, lastRequest));
3476
3461
  });
3477
3462
 
3478
3463
  responseStream.on('end', function handleStreamEnd() {
@@ -3486,7 +3471,7 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
3486
3471
  }
3487
3472
  response.data = responseData;
3488
3473
  } catch (err) {
3489
- return reject(AxiosError.from(err, null, config, response.request, response));
3474
+ return reject(AxiosError$1.from(err, null, config, response.request, response));
3490
3475
  }
3491
3476
  settle(resolve, reject, response);
3492
3477
  });
@@ -3510,9 +3495,7 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
3510
3495
 
3511
3496
  // Handle errors
3512
3497
  req.on('error', function handleRequestError(err) {
3513
- // @todo remove
3514
- // if (req.aborted && err.code !== AxiosError.ERR_FR_TOO_MANY_REDIRECTS) return;
3515
- reject(AxiosError.from(err, null, config, req));
3498
+ reject(AxiosError$1.from(err, null, config, req));
3516
3499
  });
3517
3500
 
3518
3501
  // set tcp keep alive to prevent drop connection by peer
@@ -3527,9 +3510,9 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
3527
3510
  const timeout = parseInt(config.timeout, 10);
3528
3511
 
3529
3512
  if (Number.isNaN(timeout)) {
3530
- abort(new AxiosError(
3513
+ abort(new AxiosError$1(
3531
3514
  'error trying to parse `config.timeout` to int',
3532
- AxiosError.ERR_BAD_OPTION_VALUE,
3515
+ AxiosError$1.ERR_BAD_OPTION_VALUE,
3533
3516
  config,
3534
3517
  req
3535
3518
  ));
@@ -3549,9 +3532,9 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
3549
3532
  if (config.timeoutErrorMessage) {
3550
3533
  timeoutErrorMessage = config.timeoutErrorMessage;
3551
3534
  }
3552
- abort(new AxiosError(
3535
+ abort(new AxiosError$1(
3553
3536
  timeoutErrorMessage,
3554
- transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED,
3537
+ transitional.clarifyTimeoutError ? AxiosError$1.ETIMEDOUT : AxiosError$1.ECONNABORTED,
3555
3538
  config,
3556
3539
  req
3557
3540
  ));
@@ -3578,7 +3561,7 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
3578
3561
 
3579
3562
  data.on('close', () => {
3580
3563
  if (!ended && !errored) {
3581
- abort(new CanceledError('Request stream has been aborted', config, req));
3564
+ abort(new CanceledError$1('Request stream has been aborted', config, req));
3582
3565
  }
3583
3566
  });
3584
3567
 
@@ -3671,7 +3654,7 @@ function mergeConfig(config1, config2) {
3671
3654
 
3672
3655
  function getMergedValue(target, source, prop, caseless) {
3673
3656
  if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
3674
- return utils$1.merge.call({caseless}, target, source);
3657
+ return utils$1.merge.call({ caseless }, target, source);
3675
3658
  } else if (utils$1.isPlainObject(source)) {
3676
3659
  return utils$1.merge({}, source);
3677
3660
  } else if (utils$1.isArray(source)) {
@@ -3680,7 +3663,6 @@ function mergeConfig(config1, config2) {
3680
3663
  return source;
3681
3664
  }
3682
3665
 
3683
- // eslint-disable-next-line consistent-return
3684
3666
  function mergeDeepProperties(a, b, prop, caseless) {
3685
3667
  if (!utils$1.isUndefined(b)) {
3686
3668
  return getMergedValue(a, b, prop, caseless);
@@ -3746,7 +3728,7 @@ function mergeConfig(config1, config2) {
3746
3728
  headers: (a, b, prop) => mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true)
3747
3729
  };
3748
3730
 
3749
- utils$1.forEach(Object.keys({...config1, ...config2}), function computeConfigValue(prop) {
3731
+ utils$1.forEach(Object.keys({ ...config1, ...config2 }), function computeConfigValue(prop) {
3750
3732
  const merge = mergeMap[prop] || mergeDeepProperties;
3751
3733
  const configValue = merge(config1[prop], config2[prop], prop);
3752
3734
  (utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
@@ -3895,7 +3877,7 @@ const xhrAdapter = isXHRAdapterSupported && function (config) {
3895
3877
  return;
3896
3878
  }
3897
3879
 
3898
- reject(new AxiosError('Request aborted', AxiosError.ECONNABORTED, config, request));
3880
+ reject(new AxiosError$1('Request aborted', AxiosError$1.ECONNABORTED, config, request));
3899
3881
 
3900
3882
  // Clean up request
3901
3883
  request = null;
@@ -3907,7 +3889,7 @@ const xhrAdapter = isXHRAdapterSupported && function (config) {
3907
3889
  // (message may be empty; when present, surface it)
3908
3890
  // See https://developer.mozilla.org/docs/Web/API/XMLHttpRequest/error_event
3909
3891
  const msg = event && event.message ? event.message : 'Network Error';
3910
- const err = new AxiosError(msg, AxiosError.ERR_NETWORK, config, request);
3892
+ const err = new AxiosError$1(msg, AxiosError$1.ERR_NETWORK, config, request);
3911
3893
  // attach the underlying event for consumers who want details
3912
3894
  err.event = event || null;
3913
3895
  reject(err);
@@ -3921,9 +3903,9 @@ const xhrAdapter = isXHRAdapterSupported && function (config) {
3921
3903
  if (_config.timeoutErrorMessage) {
3922
3904
  timeoutErrorMessage = _config.timeoutErrorMessage;
3923
3905
  }
3924
- reject(new AxiosError(
3906
+ reject(new AxiosError$1(
3925
3907
  timeoutErrorMessage,
3926
- transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED,
3908
+ transitional.clarifyTimeoutError ? AxiosError$1.ETIMEDOUT : AxiosError$1.ECONNABORTED,
3927
3909
  config,
3928
3910
  request));
3929
3911
 
@@ -3973,7 +3955,7 @@ const xhrAdapter = isXHRAdapterSupported && function (config) {
3973
3955
  if (!request) {
3974
3956
  return;
3975
3957
  }
3976
- reject(!cancel || cancel.type ? new CanceledError(null, config, request) : cancel);
3958
+ reject(!cancel || cancel.type ? new CanceledError$1(null, config, request) : cancel);
3977
3959
  request.abort();
3978
3960
  request = null;
3979
3961
  };
@@ -3987,7 +3969,7 @@ const xhrAdapter = isXHRAdapterSupported && function (config) {
3987
3969
  const protocol = parseProtocol(_config.url);
3988
3970
 
3989
3971
  if (protocol && platform.protocols.indexOf(protocol) === -1) {
3990
- reject(new AxiosError('Unsupported protocol ' + protocol + ':', AxiosError.ERR_BAD_REQUEST, config));
3972
+ reject(new AxiosError$1('Unsupported protocol ' + protocol + ':', AxiosError$1.ERR_BAD_REQUEST, config));
3991
3973
  return;
3992
3974
  }
3993
3975
 
@@ -4010,13 +3992,13 @@ const composeSignals = (signals, timeout) => {
4010
3992
  aborted = true;
4011
3993
  unsubscribe();
4012
3994
  const err = reason instanceof Error ? reason : this.reason;
4013
- controller.abort(err instanceof AxiosError ? err : new CanceledError(err instanceof Error ? err.message : err));
3995
+ controller.abort(err instanceof AxiosError$1 ? err : new CanceledError$1(err instanceof Error ? err.message : err));
4014
3996
  }
4015
3997
  };
4016
3998
 
4017
3999
  let timer = timeout && setTimeout(() => {
4018
4000
  timer = null;
4019
- onabort(new AxiosError(`timeout ${timeout} of ms exceeded`, AxiosError.ETIMEDOUT));
4001
+ onabort(new AxiosError$1(`timeout of ${timeout}ms exceeded`, AxiosError$1.ETIMEDOUT));
4020
4002
  }, timeout);
4021
4003
 
4022
4004
  const unsubscribe = () => {
@@ -4202,7 +4184,7 @@ const factory = (env) => {
4202
4184
  return method.call(res);
4203
4185
  }
4204
4186
 
4205
- throw new AxiosError(`Response type '${type}' is not supported`, AxiosError.ERR_NOT_SUPPORT, config);
4187
+ throw new AxiosError$1(`Response type '${type}' is not supported`, AxiosError$1.ERR_NOT_SUPPORT, config);
4206
4188
  });
4207
4189
  });
4208
4190
  })());
@@ -4368,14 +4350,14 @@ const factory = (env) => {
4368
4350
 
4369
4351
  if (err && err.name === 'TypeError' && /Load failed|fetch/i.test(err.message)) {
4370
4352
  throw Object.assign(
4371
- new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request),
4353
+ new AxiosError$1('Network Error', AxiosError$1.ERR_NETWORK, config, request),
4372
4354
  {
4373
4355
  cause: err.cause || err
4374
4356
  }
4375
4357
  )
4376
4358
  }
4377
4359
 
4378
- throw AxiosError.from(err, err && err.code, config, request);
4360
+ throw AxiosError$1.from(err, err && err.code, config, request);
4379
4361
  }
4380
4362
  }
4381
4363
  };
@@ -4480,7 +4462,7 @@ function getAdapter(adapters, config) {
4480
4462
  adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];
4481
4463
 
4482
4464
  if (adapter === undefined) {
4483
- throw new AxiosError(`Unknown adapter '${id}'`);
4465
+ throw new AxiosError$1(`Unknown adapter '${id}'`);
4484
4466
  }
4485
4467
  }
4486
4468
 
@@ -4501,7 +4483,7 @@ function getAdapter(adapters, config) {
4501
4483
  (reasons.length > 1 ? 'since :\n' + reasons.map(renderReason).join('\n') : ' ' + renderReason(reasons[0])) :
4502
4484
  'as no adapter specified';
4503
4485
 
4504
- throw new AxiosError(
4486
+ throw new AxiosError$1(
4505
4487
  `There is no suitable adapter to dispatch the request ` + s,
4506
4488
  'ERR_NOT_SUPPORT'
4507
4489
  );
@@ -4540,7 +4522,7 @@ function throwIfCancellationRequested(config) {
4540
4522
  }
4541
4523
 
4542
4524
  if (config.signal && config.signal.aborted) {
4543
- throw new CanceledError(null, config);
4525
+ throw new CanceledError$1(null, config);
4544
4526
  }
4545
4527
  }
4546
4528
 
@@ -4628,9 +4610,9 @@ validators$1.transitional = function transitional(validator, version, message) {
4628
4610
  // eslint-disable-next-line func-names
4629
4611
  return (value, opt, opts) => {
4630
4612
  if (validator === false) {
4631
- throw new AxiosError(
4613
+ throw new AxiosError$1(
4632
4614
  formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')),
4633
- AxiosError.ERR_DEPRECATED
4615
+ AxiosError$1.ERR_DEPRECATED
4634
4616
  );
4635
4617
  }
4636
4618
 
@@ -4669,7 +4651,7 @@ validators$1.spelling = function spelling(correctSpelling) {
4669
4651
 
4670
4652
  function assertOptions(options, schema, allowUnknown) {
4671
4653
  if (typeof options !== 'object') {
4672
- throw new AxiosError('options must be an object', AxiosError.ERR_BAD_OPTION_VALUE);
4654
+ throw new AxiosError$1('options must be an object', AxiosError$1.ERR_BAD_OPTION_VALUE);
4673
4655
  }
4674
4656
  const keys = Object.keys(options);
4675
4657
  let i = keys.length;
@@ -4680,12 +4662,12 @@ function assertOptions(options, schema, allowUnknown) {
4680
4662
  const value = options[opt];
4681
4663
  const result = value === undefined || validator(value, opt, options);
4682
4664
  if (result !== true) {
4683
- throw new AxiosError('option ' + opt + ' must be ' + result, AxiosError.ERR_BAD_OPTION_VALUE);
4665
+ throw new AxiosError$1('option ' + opt + ' must be ' + result, AxiosError$1.ERR_BAD_OPTION_VALUE);
4684
4666
  }
4685
4667
  continue;
4686
4668
  }
4687
4669
  if (allowUnknown !== true) {
4688
- throw new AxiosError('Unknown option ' + opt, AxiosError.ERR_BAD_OPTION);
4670
+ throw new AxiosError$1('Unknown option ' + opt, AxiosError$1.ERR_BAD_OPTION);
4689
4671
  }
4690
4672
  }
4691
4673
  }
@@ -4843,8 +4825,13 @@ class Axios {
4843
4825
 
4844
4826
  promise = Promise.resolve(config);
4845
4827
 
4828
+ let prevResult = config;
4846
4829
  while (i < len) {
4847
- promise = promise.then(chain[i++], chain[i++]);
4830
+ promise = promise
4831
+ .then(chain[i++])
4832
+ .then(result => { prevResult = result !== undefined ? result : prevResult; })
4833
+ .catch(chain[i++])
4834
+ .then(() => prevResult);
4848
4835
  }
4849
4836
 
4850
4837
  return promise;
@@ -4875,7 +4862,7 @@ class Axios {
4875
4862
  len = responseInterceptorChain.length;
4876
4863
 
4877
4864
  while (i < len) {
4878
- promise = promise.then(responseInterceptorChain[i++], responseInterceptorChain[i++]);
4865
+ promise = promise.then(responseInterceptorChain[i++]).catch(responseInterceptorChain[i++]);
4879
4866
  }
4880
4867
 
4881
4868
  return promise;
@@ -4978,7 +4965,7 @@ class CancelToken {
4978
4965
  return;
4979
4966
  }
4980
4967
 
4981
- token.reason = new CanceledError(message, config, request);
4968
+ token.reason = new CanceledError$1(message, config, request);
4982
4969
  resolvePromise(token.reason);
4983
4970
  });
4984
4971
  }
@@ -5062,7 +5049,7 @@ const CancelToken$1 = CancelToken;
5062
5049
  *
5063
5050
  * ```js
5064
5051
  * function f(x, y, z) {}
5065
- * var args = [1, 2, 3];
5052
+ * const args = [1, 2, 3];
5066
5053
  * f.apply(null, args);
5067
5054
  * ```
5068
5055
  *
@@ -5203,14 +5190,14 @@ const axios = createInstance(defaults$1);
5203
5190
  axios.Axios = Axios$1;
5204
5191
 
5205
5192
  // Expose Cancel & CancelToken
5206
- axios.CanceledError = CanceledError;
5193
+ axios.CanceledError = CanceledError$1;
5207
5194
  axios.CancelToken = CancelToken$1;
5208
5195
  axios.isCancel = isCancel;
5209
5196
  axios.VERSION = VERSION;
5210
5197
  axios.toFormData = toFormData;
5211
5198
 
5212
5199
  // Expose AxiosError class
5213
- axios.AxiosError = AxiosError;
5200
+ axios.AxiosError = AxiosError$1;
5214
5201
 
5215
5202
  // alias for CanceledError for backward compatibility
5216
5203
  axios.Cancel = axios.CanceledError;