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.

package/dist/esm/axios.js CHANGED
@@ -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
  function bind(fn, thisArg) {
3
3
  return function wrap() {
4
4
  return fn.apply(thisArg, arguments);
@@ -543,8 +543,9 @@ const reduceDescriptors = (obj, reducer) => {
543
543
  const reducedDescriptors = {};
544
544
 
545
545
  forEach(descriptors, (descriptor, name) => {
546
- if (reducer(descriptor, name, obj) !== false) {
547
- reducedDescriptors[name] = descriptor;
546
+ let ret;
547
+ if ((ret = reducer(descriptor, name, obj)) !== false) {
548
+ reducedDescriptors[name] = ret || descriptor;
548
549
  }
549
550
  });
550
551
 
@@ -1386,10 +1387,6 @@ function formDataToJSON(formData) {
1386
1387
  return null;
1387
1388
  }
1388
1389
 
1389
- const DEFAULT_CONTENT_TYPE = {
1390
- 'Content-Type': undefined
1391
- };
1392
-
1393
1390
  /**
1394
1391
  * It takes a string, tries to parse it, and if it fails, it returns the stringified version
1395
1392
  * of the input
@@ -1419,7 +1416,7 @@ const defaults = {
1419
1416
 
1420
1417
  transitional: transitionalDefaults,
1421
1418
 
1422
- adapter: ['xhr', 'http'],
1419
+ adapter: platform.isNode ? 'http' : 'xhr',
1423
1420
 
1424
1421
  transformRequest: [function transformRequest(data, headers) {
1425
1422
  const contentType = headers.getContentType() || '';
@@ -1528,19 +1525,16 @@ const defaults = {
1528
1525
 
1529
1526
  headers: {
1530
1527
  common: {
1531
- 'Accept': 'application/json, text/plain, */*'
1528
+ 'Accept': 'application/json, text/plain, */*',
1529
+ 'Content-Type': undefined
1532
1530
  }
1533
1531
  }
1534
1532
  };
1535
1533
 
1536
- utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
1534
+ utils.forEach(['delete', 'get', 'head', 'post', 'put', 'patch'], (method) => {
1537
1535
  defaults.headers[method] = {};
1538
1536
  });
1539
1537
 
1540
- utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
1541
- defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
1542
- });
1543
-
1544
1538
  const defaults$1 = defaults;
1545
1539
 
1546
1540
  // RawAxiosHeaders whose duplicates are ignored by node
@@ -1874,7 +1868,17 @@ class AxiosHeaders$1 {
1874
1868
 
1875
1869
  AxiosHeaders$1.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent', 'Authorization']);
1876
1870
 
1877
- utils.freezeMethods(AxiosHeaders$1.prototype);
1871
+ // reserved names hotfix
1872
+ utils.reduceDescriptors(AxiosHeaders$1.prototype, ({value}, key) => {
1873
+ let mapped = key[0].toUpperCase() + key.slice(1); // map `set` => `Set`
1874
+ return {
1875
+ get: () => value,
1876
+ set(headerValue) {
1877
+ this[mapped] = headerValue;
1878
+ }
1879
+ }
1880
+ });
1881
+
1878
1882
  utils.freezeMethods(AxiosHeaders$1);
1879
1883
 
1880
1884
  const AxiosHeaders$2 = AxiosHeaders$1;
@@ -2629,7 +2633,7 @@ function mergeConfig$1(config1, config2) {
2629
2633
  return config;
2630
2634
  }
2631
2635
 
2632
- const VERSION$1 = "1.4.0";
2636
+ const VERSION$1 = "1.5.0";
2633
2637
 
2634
2638
  const validators$1 = {};
2635
2639
 
@@ -2782,15 +2786,13 @@ class Axios$1 {
2782
2786
  // Set config.method
2783
2787
  config.method = (config.method || this.defaults.method || 'get').toLowerCase();
2784
2788
 
2785
- let contextHeaders;
2786
-
2787
2789
  // Flatten headers
2788
- contextHeaders = headers && utils.merge(
2790
+ let contextHeaders = headers && utils.merge(
2789
2791
  headers.common,
2790
2792
  headers[config.method]
2791
2793
  );
2792
2794
 
2793
- contextHeaders && utils.forEach(
2795
+ headers && utils.forEach(
2794
2796
  ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
2795
2797
  (method) => {
2796
2798
  delete headers[method];
@@ -3200,6 +3202,8 @@ axios.AxiosHeaders = AxiosHeaders$2;
3200
3202
 
3201
3203
  axios.formToJSON = thing => formDataToJSON(utils.isHTMLForm(thing) ? new FormData(thing) : thing);
3202
3204
 
3205
+ axios.getAdapter = adapters.getAdapter;
3206
+
3203
3207
  axios.HttpStatusCode = HttpStatusCode$2;
3204
3208
 
3205
3209
  axios.default = axios;
@@ -3225,8 +3229,9 @@ const {
3225
3229
  AxiosHeaders,
3226
3230
  HttpStatusCode,
3227
3231
  formToJSON,
3232
+ getAdapter,
3228
3233
  mergeConfig
3229
3234
  } = axios$1;
3230
3235
 
3231
- export { Axios, AxiosError, AxiosHeaders, Cancel, CancelToken, CanceledError, HttpStatusCode, VERSION, all, axios$1 as default, formToJSON, isAxiosError, isCancel, mergeConfig, spread, toFormData };
3236
+ export { Axios, AxiosError, AxiosHeaders, Cancel, CancelToken, CanceledError, HttpStatusCode, VERSION, all, axios$1 as default, formToJSON, getAdapter, isAxiosError, isCancel, mergeConfig, spread, toFormData };
3232
3237
  //# sourceMappingURL=axios.js.map