axios 1.4.0 → 1.5.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.

Potentially problematic release.


This version of axios might be problematic. Click here for more details.

@@ -1,4 +1,4 @@
1
- // Axios v1.4.0 Copyright (c) 2023 Matt Zabriskie and contributors
1
+ // Axios v1.5.0 Copyright (c) 2023 Matt Zabriskie and contributors
2
2
  'use strict';
3
3
 
4
4
  function bind(fn, thisArg) {
@@ -545,8 +545,9 @@ const reduceDescriptors = (obj, reducer) => {
545
545
  const reducedDescriptors = {};
546
546
 
547
547
  forEach(descriptors, (descriptor, name) => {
548
- if (reducer(descriptor, name, obj) !== false) {
549
- reducedDescriptors[name] = descriptor;
548
+ let ret;
549
+ if ((ret = reducer(descriptor, name, obj)) !== false) {
550
+ reducedDescriptors[name] = ret || descriptor;
550
551
  }
551
552
  });
552
553
 
@@ -1388,10 +1389,6 @@ function formDataToJSON(formData) {
1388
1389
  return null;
1389
1390
  }
1390
1391
 
1391
- const DEFAULT_CONTENT_TYPE = {
1392
- 'Content-Type': undefined
1393
- };
1394
-
1395
1392
  /**
1396
1393
  * It takes a string, tries to parse it, and if it fails, it returns the stringified version
1397
1394
  * of the input
@@ -1421,7 +1418,7 @@ const defaults = {
1421
1418
 
1422
1419
  transitional: transitionalDefaults,
1423
1420
 
1424
- adapter: ['xhr', 'http'],
1421
+ adapter: platform.isNode ? 'http' : 'xhr',
1425
1422
 
1426
1423
  transformRequest: [function transformRequest(data, headers) {
1427
1424
  const contentType = headers.getContentType() || '';
@@ -1530,19 +1527,16 @@ const defaults = {
1530
1527
 
1531
1528
  headers: {
1532
1529
  common: {
1533
- 'Accept': 'application/json, text/plain, */*'
1530
+ 'Accept': 'application/json, text/plain, */*',
1531
+ 'Content-Type': undefined
1534
1532
  }
1535
1533
  }
1536
1534
  };
1537
1535
 
1538
- utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
1536
+ utils.forEach(['delete', 'get', 'head', 'post', 'put', 'patch'], (method) => {
1539
1537
  defaults.headers[method] = {};
1540
1538
  });
1541
1539
 
1542
- utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
1543
- defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
1544
- });
1545
-
1546
1540
  var defaults$1 = defaults;
1547
1541
 
1548
1542
  // RawAxiosHeaders whose duplicates are ignored by node
@@ -1876,7 +1870,17 @@ class AxiosHeaders {
1876
1870
 
1877
1871
  AxiosHeaders.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent', 'Authorization']);
1878
1872
 
1879
- utils.freezeMethods(AxiosHeaders.prototype);
1873
+ // reserved names hotfix
1874
+ utils.reduceDescriptors(AxiosHeaders.prototype, ({value}, key) => {
1875
+ let mapped = key[0].toUpperCase() + key.slice(1); // map `set` => `Set`
1876
+ return {
1877
+ get: () => value,
1878
+ set(headerValue) {
1879
+ this[mapped] = headerValue;
1880
+ }
1881
+ }
1882
+ });
1883
+
1880
1884
  utils.freezeMethods(AxiosHeaders);
1881
1885
 
1882
1886
  var AxiosHeaders$1 = AxiosHeaders;
@@ -2631,7 +2635,7 @@ function mergeConfig(config1, config2) {
2631
2635
  return config;
2632
2636
  }
2633
2637
 
2634
- const VERSION = "1.4.0";
2638
+ const VERSION = "1.5.0";
2635
2639
 
2636
2640
  const validators$1 = {};
2637
2641
 
@@ -2784,15 +2788,13 @@ class Axios {
2784
2788
  // Set config.method
2785
2789
  config.method = (config.method || this.defaults.method || 'get').toLowerCase();
2786
2790
 
2787
- let contextHeaders;
2788
-
2789
2791
  // Flatten headers
2790
- contextHeaders = headers && utils.merge(
2792
+ let contextHeaders = headers && utils.merge(
2791
2793
  headers.common,
2792
2794
  headers[config.method]
2793
2795
  );
2794
2796
 
2795
- contextHeaders && utils.forEach(
2797
+ headers && utils.forEach(
2796
2798
  ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
2797
2799
  (method) => {
2798
2800
  delete headers[method];
@@ -3202,6 +3204,8 @@ axios.AxiosHeaders = AxiosHeaders$1;
3202
3204
 
3203
3205
  axios.formToJSON = thing => formDataToJSON(utils.isHTMLForm(thing) ? new FormData(thing) : thing);
3204
3206
 
3207
+ axios.getAdapter = adapters.getAdapter;
3208
+
3205
3209
  axios.HttpStatusCode = HttpStatusCode$1;
3206
3210
 
3207
3211
  axios.default = axios;