axios 1.3.6 → 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.3.6 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
 
@@ -667,6 +668,11 @@ const toJSONObject = (obj) => {
667
668
  return visit(obj, 0);
668
669
  };
669
670
 
671
+ const isAsyncFn = kindOfTest('AsyncFunction');
672
+
673
+ const isThenable = (thing) =>
674
+ thing && (isObject(thing) || isFunction(thing)) && isFunction(thing.then) && isFunction(thing.catch);
675
+
670
676
  var utils = {
671
677
  isArray,
672
678
  isArrayBuffer,
@@ -716,7 +722,9 @@ var utils = {
716
722
  ALPHABET,
717
723
  generateString,
718
724
  isSpecCompliantForm,
719
- toJSONObject
725
+ toJSONObject,
726
+ isAsyncFn,
727
+ isThenable
720
728
  };
721
729
 
722
730
  /**
@@ -1381,10 +1389,6 @@ function formDataToJSON(formData) {
1381
1389
  return null;
1382
1390
  }
1383
1391
 
1384
- const DEFAULT_CONTENT_TYPE = {
1385
- 'Content-Type': undefined
1386
- };
1387
-
1388
1392
  /**
1389
1393
  * It takes a string, tries to parse it, and if it fails, it returns the stringified version
1390
1394
  * of the input
@@ -1414,7 +1418,7 @@ const defaults = {
1414
1418
 
1415
1419
  transitional: transitionalDefaults,
1416
1420
 
1417
- adapter: ['xhr', 'http'],
1421
+ adapter: platform.isNode ? 'http' : 'xhr',
1418
1422
 
1419
1423
  transformRequest: [function transformRequest(data, headers) {
1420
1424
  const contentType = headers.getContentType() || '';
@@ -1523,19 +1527,16 @@ const defaults = {
1523
1527
 
1524
1528
  headers: {
1525
1529
  common: {
1526
- 'Accept': 'application/json, text/plain, */*'
1530
+ 'Accept': 'application/json, text/plain, */*',
1531
+ 'Content-Type': undefined
1527
1532
  }
1528
1533
  }
1529
1534
  };
1530
1535
 
1531
- utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
1536
+ utils.forEach(['delete', 'get', 'head', 'post', 'put', 'patch'], (method) => {
1532
1537
  defaults.headers[method] = {};
1533
1538
  });
1534
1539
 
1535
- utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
1536
- defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
1537
- });
1538
-
1539
1540
  var defaults$1 = defaults;
1540
1541
 
1541
1542
  // RawAxiosHeaders whose duplicates are ignored by node
@@ -1869,7 +1870,17 @@ class AxiosHeaders {
1869
1870
 
1870
1871
  AxiosHeaders.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent', 'Authorization']);
1871
1872
 
1872
- 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
+
1873
1884
  utils.freezeMethods(AxiosHeaders);
1874
1885
 
1875
1886
  var AxiosHeaders$1 = AxiosHeaders;
@@ -2204,8 +2215,12 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
2204
2215
  }
2205
2216
  }
2206
2217
 
2207
- if (utils.isFormData(requestData) && (platform.isStandardBrowserEnv || platform.isStandardBrowserWebWorkerEnv)) {
2208
- requestHeaders.setContentType(false); // Let the browser set it
2218
+ if (utils.isFormData(requestData)) {
2219
+ if (platform.isStandardBrowserEnv || platform.isStandardBrowserWebWorkerEnv) {
2220
+ requestHeaders.setContentType(false); // Let the browser set it
2221
+ } else {
2222
+ requestHeaders.setContentType('multipart/form-data;', false); // mobile/desktop app frameworks
2223
+ }
2209
2224
  }
2210
2225
 
2211
2226
  let request = new XMLHttpRequest();
@@ -2611,7 +2626,7 @@ function mergeConfig(config1, config2) {
2611
2626
  headers: (a, b) => mergeDeepProperties(headersToObject(a), headersToObject(b), true)
2612
2627
  };
2613
2628
 
2614
- utils.forEach(Object.keys(config1).concat(Object.keys(config2)), function computeConfigValue(prop) {
2629
+ utils.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
2615
2630
  const merge = mergeMap[prop] || mergeDeepProperties;
2616
2631
  const configValue = merge(config1[prop], config2[prop], prop);
2617
2632
  (utils.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
@@ -2620,7 +2635,7 @@ function mergeConfig(config1, config2) {
2620
2635
  return config;
2621
2636
  }
2622
2637
 
2623
- const VERSION = "1.3.6";
2638
+ const VERSION = "1.5.0";
2624
2639
 
2625
2640
  const validators$1 = {};
2626
2641
 
@@ -2773,15 +2788,13 @@ class Axios {
2773
2788
  // Set config.method
2774
2789
  config.method = (config.method || this.defaults.method || 'get').toLowerCase();
2775
2790
 
2776
- let contextHeaders;
2777
-
2778
2791
  // Flatten headers
2779
- contextHeaders = headers && utils.merge(
2792
+ let contextHeaders = headers && utils.merge(
2780
2793
  headers.common,
2781
2794
  headers[config.method]
2782
2795
  );
2783
2796
 
2784
- contextHeaders && utils.forEach(
2797
+ headers && utils.forEach(
2785
2798
  ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
2786
2799
  (method) => {
2787
2800
  delete headers[method];
@@ -3191,6 +3204,8 @@ axios.AxiosHeaders = AxiosHeaders$1;
3191
3204
 
3192
3205
  axios.formToJSON = thing => formDataToJSON(utils.isHTMLForm(thing) ? new FormData(thing) : thing);
3193
3206
 
3207
+ axios.getAdapter = adapters.getAdapter;
3208
+
3194
3209
  axios.HttpStatusCode = HttpStatusCode$1;
3195
3210
 
3196
3211
  axios.default = axios;