axios 0.24.0 → 0.26.1

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/CHANGELOG.md CHANGED
@@ -1,9 +1,79 @@
1
1
  # Changelog
2
2
 
3
+ ### 0.26.1 (March 9, 2022)
4
+
5
+ Fixes and Functionality:
6
+ - Refactored project file structure to avoid circular imports ([##4220](https://github.com/axios/axios/pull/#4220))
7
+
8
+ ### 0.26.0 (February 13, 2022)
9
+
10
+ Fixes and Functionality:
11
+ - Fixed The timeoutErrorMessage property in config not work with Node.js ([#3581](https://github.com/axios/axios/pull/3581))
12
+ - Added errors to be displayed when the query parsing process itself fails ([#3961](https://github.com/axios/axios/pull/3961))
13
+ - Fix/remove url required ([#4426](https://github.com/axios/axios/pull/4426))
14
+ - Update follow-redirects dependency due to Vurnerbility ([#4462](https://github.com/axios/axios/pull/4462))
15
+ - Bump karma from 6.3.11 to 6.3.14 ([#4461](https://github.com/axios/axios/pull/4461))
16
+ - Bump follow-redirects from 1.14.7 to 1.14.8 ([#4473](https://github.com/axios/axios/pull/4473))
17
+
18
+ ### 0.25.0 (January 18, 2022)
19
+
20
+ Breaking changes:
21
+ - Fixing maxBodyLength enforcement ([#3786](https://github.com/axios/axios/pull/3786))
22
+ - Don't rely on strict mode behaviour for arguments ([#3470](https://github.com/axios/axios/pull/3470))
23
+ - Adding error handling when missing url ([#3791](https://github.com/axios/axios/pull/3791))
24
+ - Update isAbsoluteURL.js removing escaping of non-special characters ([#3809](https://github.com/axios/axios/pull/3809))
25
+ - Use native Array.isArray() in utils.js ([#3836](https://github.com/axios/axios/pull/3836))
26
+ - Adding error handling inside stream end callback ([#3967](https://github.com/axios/axios/pull/3967))
27
+
28
+ Fixes and Functionality:
29
+ - Added aborted even handler ([#3916](https://github.com/axios/axios/pull/3916))
30
+ - Header types expanded allowing `boolean` and `number` types ([#4144](https://github.com/axios/axios/pull/4144))
31
+ - Fix cancel signature allowing cancel message to be `undefined` ([#3153](https://github.com/axios/axios/pull/3153))
32
+ - Updated type checks to be formulated better ([#3342](https://github.com/axios/axios/pull/3342))
33
+ - Avoid unnecessary buffer allocations ([#3321](https://github.com/axios/axios/pull/3321))
34
+ - Adding a socket handler to keep TCP connection live when processing long living requests ([#3422](https://github.com/axios/axios/pull/3422))
35
+ - Added toFormData helper function ([#3757](https://github.com/axios/axios/pull/3757))
36
+ - Adding responseEncoding prop type in AxiosRequestConfig ([#3918](https://github.com/axios/axios/pull/3918))
37
+
38
+ Internal and Tests:
39
+ - Adding axios-test-instance to ecosystem ([#3786](https://github.com/axios/axios/pull/3786))
40
+ - Optimize the logic of isAxiosError ([#3546](https://github.com/axios/axios/pull/3546))
41
+ - Add tests and documentation to display how multiple inceptors work ([#3564](https://github.com/axios/axios/pull/3564))
42
+ - Updating follow-redirects to version 1.14.7 ([#4379](https://github.com/axios/axios/pull/4379))
43
+
44
+
45
+ Documentation:
46
+ - Fixing changelog to show corrext pull request ([#4219](https://github.com/axios/axios/pull/4219))
47
+ - Update upgrade guide for https proxy setting ([#3604](https://github.com/axios/axios/pull/3604))
48
+
49
+ Huge thanks to everyone who contributed to this release via code (authors listed below) or via reviews and triaging on GitHub:
50
+
51
+ - [Jay](mailto:jasonsaayman@gmail.com)
52
+ - [Rijk van Zanten](https://github.com/rijkvanzanten)
53
+ - [Kohta Ito](https://github.com/koh110)
54
+ - [Brandon Faulkner](https://github.com/bfaulk96)
55
+ - [Stefano Magni](https://github.com/NoriSte)
56
+ - [enofan](https://github.com/fanguangyi)
57
+ - [Andrey Pechkurov](https://github.com/puzpuzpuz)
58
+ - [Doowonee](https://github.com/doowonee)
59
+ - [Emil Broman](https://github.com/emilbroman-eqt)
60
+ - [Remco Haszing](https://github.com/remcohaszing)
61
+ - [Black-Hole](https://github.com/BlackHole1)
62
+ - [Wolfram Kriesing](https://github.com/wolframkriesing)
63
+ - [Andrew Ovens](https://github.com/repl-andrew-ovens)
64
+ - [Paulo Renato](https://github.com/PauloRSF)
65
+ - [Ben Carp](https://github.com/carpben)
66
+ - [Hirotaka Tagawa](https://github.com/wafuwafu13)
67
+ - [狼族小狈](https://github.com/lzxb)
68
+ - [C. Lewis](https://github.com/ctjlewis)
69
+ - [Felipe Carvalho](https://github.com/FCarvalhoVII)
70
+ - [Daniel](https://github.com/djs113)
71
+ - [Gustavo Sales](https://github.com/gussalesdev)
72
+
3
73
  ### 0.24.0 (October 25, 2021)
4
74
 
5
75
  Breaking changes:
6
- - Revert: change type of AxiosResponse to any, please read lengthy discussion here: ([4141](https://github.com/axios/axios/issues/4141)) pull request: ([#4114](https://github.com/axios/axios/pull/4114))
76
+ - Revert: change type of AxiosResponse to any, please read lengthy discussion here: ([#4141](https://github.com/axios/axios/issues/4141)) pull request: ([#4186](https://github.com/axios/axios/pull/4186))
7
77
 
8
78
  Huge thanks to everyone who contributed to this release via code (authors listed below) or via reviews and triaging on GitHub:
9
79
 
package/README.md CHANGED
@@ -9,6 +9,7 @@
9
9
  [![npm downloads](https://img.shields.io/npm/dm/axios.svg?style=flat-square)](http://npm-stat.com/charts.html?package=axios)
10
10
  [![gitter chat](https://img.shields.io/gitter/room/mzabriskie/axios.svg?style=flat-square)](https://gitter.im/mzabriskie/axios)
11
11
  [![code helpers](https://www.codetriage.com/axios/axios/badges/users.svg)](https://www.codetriage.com/axios/axios)
12
+ [![Known Vulnerabilities](https://snyk.io/test/npm/axios/badge.svg)](https://snyk.io/test/npm/axios)
12
13
 
13
14
  Promise based HTTP client for the browser and node.js
14
15
 
@@ -32,6 +33,7 @@ Promise based HTTP client for the browser and node.js
32
33
  - [Custom instance defaults](#custom-instance-defaults)
33
34
  - [Config order of precedence](#config-order-of-precedence)
34
35
  - [Interceptors](#interceptors)
36
+ - [Multiple Interceptors](#multiple-interceptors)
35
37
  - [Handling Errors](#handling-errors)
36
38
  - [Cancellation](#cancellation)
37
39
  - [Using application/x-www-form-urlencoded format](#using-applicationx-www-form-urlencoded-format)
@@ -645,6 +647,21 @@ axios.interceptors.request.use(function (config) {
645
647
  }, null, { runWhen: onGetCall });
646
648
  ```
647
649
 
650
+ ### Multiple Interceptors
651
+
652
+ Given you add multiple response interceptors
653
+ and when the response was fulfilled
654
+ - then each interceptor is executed
655
+ - then they are executed in the order they were added
656
+ - then only the last interceptor's result is returned
657
+ - then every interceptor receives the result of it's predecessor
658
+ - and when the fulfillment-interceptor throws
659
+ - then the following fulfillment-interceptor is not called
660
+ - then the following rejection-interceptor is called
661
+ - once caught, another following fulfill-interceptor is called again (just like in a promise chain).
662
+
663
+ Read [the interceptor tests](./test/specs/interceptors.spec.js) for seeing all this in code.
664
+
648
665
  ## Handling Errors
649
666
 
650
667
  ```js
package/UPGRADE_GUIDE.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Upgrade Guide
2
2
 
3
+ ### 0.18.x -> 0.19.0
4
+
5
+ #### HTTPS Proxies
6
+
7
+ Routing through an https proxy now requires setting the `protocol` attribute of the proxy configuration to `https`
8
+
3
9
  ### 0.15.x -> 0.16.0
4
10
 
5
11
  #### `Promise` Type Declarations
package/dist/axios.js CHANGED
@@ -125,7 +125,7 @@ var buildFullPath = __webpack_require__(/*! ../core/buildFullPath */ "./lib/core
125
125
  var parseHeaders = __webpack_require__(/*! ./../helpers/parseHeaders */ "./lib/helpers/parseHeaders.js");
126
126
  var isURLSameOrigin = __webpack_require__(/*! ./../helpers/isURLSameOrigin */ "./lib/helpers/isURLSameOrigin.js");
127
127
  var createError = __webpack_require__(/*! ../core/createError */ "./lib/core/createError.js");
128
- var defaults = __webpack_require__(/*! ../defaults */ "./lib/defaults.js");
128
+ var transitionalDefaults = __webpack_require__(/*! ../defaults/transitional */ "./lib/defaults/transitional.js");
129
129
  var Cancel = __webpack_require__(/*! ../cancel/Cancel */ "./lib/cancel/Cancel.js");
130
130
 
131
131
  module.exports = function xhrAdapter(config) {
@@ -240,7 +240,7 @@ module.exports = function xhrAdapter(config) {
240
240
  // Handle timeout
241
241
  request.ontimeout = function handleTimeout() {
242
242
  var timeoutErrorMessage = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded';
243
- var transitional = config.transitional || defaults.transitional;
243
+ var transitional = config.transitional || transitionalDefaults;
244
244
  if (config.timeoutErrorMessage) {
245
245
  timeoutErrorMessage = config.timeoutErrorMessage;
246
246
  }
@@ -345,7 +345,7 @@ var utils = __webpack_require__(/*! ./utils */ "./lib/utils.js");
345
345
  var bind = __webpack_require__(/*! ./helpers/bind */ "./lib/helpers/bind.js");
346
346
  var Axios = __webpack_require__(/*! ./core/Axios */ "./lib/core/Axios.js");
347
347
  var mergeConfig = __webpack_require__(/*! ./core/mergeConfig */ "./lib/core/mergeConfig.js");
348
- var defaults = __webpack_require__(/*! ./defaults */ "./lib/defaults.js");
348
+ var defaults = __webpack_require__(/*! ./defaults */ "./lib/defaults/index.js");
349
349
 
350
350
  /**
351
351
  * Create an instance of Axios
@@ -615,14 +615,14 @@ function Axios(instanceConfig) {
615
615
  *
616
616
  * @param {Object} config The config specific for this request (merged with this.defaults)
617
617
  */
618
- Axios.prototype.request = function request(config) {
618
+ Axios.prototype.request = function request(configOrUrl, config) {
619
619
  /*eslint no-param-reassign:0*/
620
620
  // Allow for axios('example/url'[, config]) a la fetch API
621
- if (typeof config === 'string') {
622
- config = arguments[1] || {};
623
- config.url = arguments[0];
624
- } else {
621
+ if (typeof configOrUrl === 'string') {
625
622
  config = config || {};
623
+ config.url = configOrUrl;
624
+ } else {
625
+ config = configOrUrl || {};
626
626
  }
627
627
 
628
628
  config = mergeConfig(this.defaults, config);
@@ -880,7 +880,7 @@ module.exports = function createError(message, config, code, request, response)
880
880
  var utils = __webpack_require__(/*! ./../utils */ "./lib/utils.js");
881
881
  var transformData = __webpack_require__(/*! ./transformData */ "./lib/core/transformData.js");
882
882
  var isCancel = __webpack_require__(/*! ../cancel/isCancel */ "./lib/cancel/isCancel.js");
883
- var defaults = __webpack_require__(/*! ../defaults */ "./lib/defaults.js");
883
+ var defaults = __webpack_require__(/*! ../defaults */ "./lib/defaults/index.js");
884
884
  var Cancel = __webpack_require__(/*! ../cancel/Cancel */ "./lib/cancel/Cancel.js");
885
885
 
886
886
  /**
@@ -1180,7 +1180,7 @@ module.exports = function settle(resolve, reject, response) {
1180
1180
 
1181
1181
 
1182
1182
  var utils = __webpack_require__(/*! ./../utils */ "./lib/utils.js");
1183
- var defaults = __webpack_require__(/*! ./../defaults */ "./lib/defaults.js");
1183
+ var defaults = __webpack_require__(/*! ../defaults */ "./lib/defaults/index.js");
1184
1184
 
1185
1185
  /**
1186
1186
  * Transform the data for a request or a response
@@ -1203,19 +1203,20 @@ module.exports = function transformData(data, headers, fns) {
1203
1203
 
1204
1204
  /***/ }),
1205
1205
 
1206
- /***/ "./lib/defaults.js":
1207
- /*!*************************!*\
1208
- !*** ./lib/defaults.js ***!
1209
- \*************************/
1206
+ /***/ "./lib/defaults/index.js":
1207
+ /*!*******************************!*\
1208
+ !*** ./lib/defaults/index.js ***!
1209
+ \*******************************/
1210
1210
  /*! no static exports found */
1211
1211
  /***/ (function(module, exports, __webpack_require__) {
1212
1212
 
1213
1213
  "use strict";
1214
1214
 
1215
1215
 
1216
- var utils = __webpack_require__(/*! ./utils */ "./lib/utils.js");
1217
- var normalizeHeaderName = __webpack_require__(/*! ./helpers/normalizeHeaderName */ "./lib/helpers/normalizeHeaderName.js");
1218
- var enhanceError = __webpack_require__(/*! ./core/enhanceError */ "./lib/core/enhanceError.js");
1216
+ var utils = __webpack_require__(/*! ../utils */ "./lib/utils.js");
1217
+ var normalizeHeaderName = __webpack_require__(/*! ../helpers/normalizeHeaderName */ "./lib/helpers/normalizeHeaderName.js");
1218
+ var enhanceError = __webpack_require__(/*! ../core/enhanceError */ "./lib/core/enhanceError.js");
1219
+ var transitionalDefaults = __webpack_require__(/*! ./transitional */ "./lib/defaults/transitional.js");
1219
1220
 
1220
1221
  var DEFAULT_CONTENT_TYPE = {
1221
1222
  'Content-Type': 'application/x-www-form-urlencoded'
@@ -1231,10 +1232,10 @@ function getDefaultAdapter() {
1231
1232
  var adapter;
1232
1233
  if (typeof XMLHttpRequest !== 'undefined') {
1233
1234
  // For browsers use XHR adapter
1234
- adapter = __webpack_require__(/*! ./adapters/xhr */ "./lib/adapters/xhr.js");
1235
+ adapter = __webpack_require__(/*! ../adapters/xhr */ "./lib/adapters/xhr.js");
1235
1236
  } else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {
1236
1237
  // For node use HTTP adapter
1237
- adapter = __webpack_require__(/*! ./adapters/http */ "./lib/adapters/xhr.js");
1238
+ adapter = __webpack_require__(/*! ../adapters/http */ "./lib/adapters/xhr.js");
1238
1239
  }
1239
1240
  return adapter;
1240
1241
  }
@@ -1256,11 +1257,7 @@ function stringifySafely(rawValue, parser, encoder) {
1256
1257
 
1257
1258
  var defaults = {
1258
1259
 
1259
- transitional: {
1260
- silentJSONParsing: true,
1261
- forcedJSONParsing: true,
1262
- clarifyTimeoutError: false
1263
- },
1260
+ transitional: transitionalDefaults,
1264
1261
 
1265
1262
  adapter: getDefaultAdapter(),
1266
1263
 
@@ -1347,6 +1344,25 @@ utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
1347
1344
  module.exports = defaults;
1348
1345
 
1349
1346
 
1347
+ /***/ }),
1348
+
1349
+ /***/ "./lib/defaults/transitional.js":
1350
+ /*!**************************************!*\
1351
+ !*** ./lib/defaults/transitional.js ***!
1352
+ \**************************************/
1353
+ /*! no static exports found */
1354
+ /***/ (function(module, exports, __webpack_require__) {
1355
+
1356
+ "use strict";
1357
+
1358
+
1359
+ module.exports = {
1360
+ silentJSONParsing: true,
1361
+ forcedJSONParsing: true,
1362
+ clarifyTimeoutError: false
1363
+ };
1364
+
1365
+
1350
1366
  /***/ }),
1351
1367
 
1352
1368
  /***/ "./lib/env/data.js":
@@ -1357,7 +1373,7 @@ module.exports = defaults;
1357
1373
  /***/ (function(module, exports) {
1358
1374
 
1359
1375
  module.exports = {
1360
- "version": "0.24.0"
1376
+ "version": "0.26.1"
1361
1377
  };
1362
1378
 
1363
1379
  /***/ }),
@@ -1578,7 +1594,7 @@ module.exports = function isAbsoluteURL(url) {
1578
1594
  // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
1579
1595
  // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
1580
1596
  // by any combination of letters, digits, plus, period, or hyphen.
1581
- return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url);
1597
+ return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
1582
1598
  };
1583
1599
 
1584
1600
 
@@ -1594,6 +1610,8 @@ module.exports = function isAbsoluteURL(url) {
1594
1610
  "use strict";
1595
1611
 
1596
1612
 
1613
+ var utils = __webpack_require__(/*! ./../utils */ "./lib/utils.js");
1614
+
1597
1615
  /**
1598
1616
  * Determines whether the payload is an error thrown by Axios
1599
1617
  *
@@ -1601,7 +1619,7 @@ module.exports = function isAbsoluteURL(url) {
1601
1619
  * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
1602
1620
  */
1603
1621
  module.exports = function isAxiosError(payload) {
1604
- return (typeof payload === 'object') && (payload.isAxiosError === true);
1622
+ return utils.isObject(payload) && (payload.isAxiosError === true);
1605
1623
  };
1606
1624
 
1607
1625
 
@@ -1932,7 +1950,7 @@ var toString = Object.prototype.toString;
1932
1950
  * @returns {boolean} True if value is an Array, otherwise false
1933
1951
  */
1934
1952
  function isArray(val) {
1935
- return toString.call(val) === '[object Array]';
1953
+ return Array.isArray(val);
1936
1954
  }
1937
1955
 
1938
1956
  /**
@@ -1973,7 +1991,7 @@ function isArrayBuffer(val) {
1973
1991
  * @returns {boolean} True if value is an FormData, otherwise false
1974
1992
  */
1975
1993
  function isFormData(val) {
1976
- return (typeof FormData !== 'undefined') && (val instanceof FormData);
1994
+ return toString.call(val) === '[object FormData]';
1977
1995
  }
1978
1996
 
1979
1997
  /**
@@ -1987,7 +2005,7 @@ function isArrayBufferView(val) {
1987
2005
  if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
1988
2006
  result = ArrayBuffer.isView(val);
1989
2007
  } else {
1990
- result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer);
2008
+ result = (val) && (val.buffer) && (isArrayBuffer(val.buffer));
1991
2009
  }
1992
2010
  return result;
1993
2011
  }
@@ -2094,7 +2112,7 @@ function isStream(val) {
2094
2112
  * @returns {boolean} True if value is a URLSearchParams object, otherwise false
2095
2113
  */
2096
2114
  function isURLSearchParams(val) {
2097
- return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams;
2115
+ return toString.call(val) === '[object URLSearchParams]';
2098
2116
  }
2099
2117
 
2100
2118
  /**