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.

package/dist/esm/axios.js CHANGED
@@ -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
  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
 
@@ -665,6 +666,11 @@ const toJSONObject = (obj) => {
665
666
  return visit(obj, 0);
666
667
  };
667
668
 
669
+ const isAsyncFn = kindOfTest('AsyncFunction');
670
+
671
+ const isThenable = (thing) =>
672
+ thing && (isObject(thing) || isFunction(thing)) && isFunction(thing.then) && isFunction(thing.catch);
673
+
668
674
  const utils = {
669
675
  isArray,
670
676
  isArrayBuffer,
@@ -714,7 +720,9 @@ const utils = {
714
720
  ALPHABET,
715
721
  generateString,
716
722
  isSpecCompliantForm,
717
- toJSONObject
723
+ toJSONObject,
724
+ isAsyncFn,
725
+ isThenable
718
726
  };
719
727
 
720
728
  /**
@@ -1379,10 +1387,6 @@ function formDataToJSON(formData) {
1379
1387
  return null;
1380
1388
  }
1381
1389
 
1382
- const DEFAULT_CONTENT_TYPE = {
1383
- 'Content-Type': undefined
1384
- };
1385
-
1386
1390
  /**
1387
1391
  * It takes a string, tries to parse it, and if it fails, it returns the stringified version
1388
1392
  * of the input
@@ -1412,7 +1416,7 @@ const defaults = {
1412
1416
 
1413
1417
  transitional: transitionalDefaults,
1414
1418
 
1415
- adapter: ['xhr', 'http'],
1419
+ adapter: platform.isNode ? 'http' : 'xhr',
1416
1420
 
1417
1421
  transformRequest: [function transformRequest(data, headers) {
1418
1422
  const contentType = headers.getContentType() || '';
@@ -1521,19 +1525,16 @@ const defaults = {
1521
1525
 
1522
1526
  headers: {
1523
1527
  common: {
1524
- 'Accept': 'application/json, text/plain, */*'
1528
+ 'Accept': 'application/json, text/plain, */*',
1529
+ 'Content-Type': undefined
1525
1530
  }
1526
1531
  }
1527
1532
  };
1528
1533
 
1529
- utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
1534
+ utils.forEach(['delete', 'get', 'head', 'post', 'put', 'patch'], (method) => {
1530
1535
  defaults.headers[method] = {};
1531
1536
  });
1532
1537
 
1533
- utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
1534
- defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
1535
- });
1536
-
1537
1538
  const defaults$1 = defaults;
1538
1539
 
1539
1540
  // RawAxiosHeaders whose duplicates are ignored by node
@@ -1867,7 +1868,17 @@ class AxiosHeaders$1 {
1867
1868
 
1868
1869
  AxiosHeaders$1.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent', 'Authorization']);
1869
1870
 
1870
- 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
+
1871
1882
  utils.freezeMethods(AxiosHeaders$1);
1872
1883
 
1873
1884
  const AxiosHeaders$2 = AxiosHeaders$1;
@@ -2202,8 +2213,12 @@ const xhrAdapter = isXHRAdapterSupported && function (config) {
2202
2213
  }
2203
2214
  }
2204
2215
 
2205
- if (utils.isFormData(requestData) && (platform.isStandardBrowserEnv || platform.isStandardBrowserWebWorkerEnv)) {
2206
- requestHeaders.setContentType(false); // Let the browser set it
2216
+ if (utils.isFormData(requestData)) {
2217
+ if (platform.isStandardBrowserEnv || platform.isStandardBrowserWebWorkerEnv) {
2218
+ requestHeaders.setContentType(false); // Let the browser set it
2219
+ } else {
2220
+ requestHeaders.setContentType('multipart/form-data;', false); // mobile/desktop app frameworks
2221
+ }
2207
2222
  }
2208
2223
 
2209
2224
  let request = new XMLHttpRequest();
@@ -2609,7 +2624,7 @@ function mergeConfig$1(config1, config2) {
2609
2624
  headers: (a, b) => mergeDeepProperties(headersToObject(a), headersToObject(b), true)
2610
2625
  };
2611
2626
 
2612
- utils.forEach(Object.keys(config1).concat(Object.keys(config2)), function computeConfigValue(prop) {
2627
+ utils.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
2613
2628
  const merge = mergeMap[prop] || mergeDeepProperties;
2614
2629
  const configValue = merge(config1[prop], config2[prop], prop);
2615
2630
  (utils.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
@@ -2618,7 +2633,7 @@ function mergeConfig$1(config1, config2) {
2618
2633
  return config;
2619
2634
  }
2620
2635
 
2621
- const VERSION$1 = "1.3.6";
2636
+ const VERSION$1 = "1.5.0";
2622
2637
 
2623
2638
  const validators$1 = {};
2624
2639
 
@@ -2771,15 +2786,13 @@ class Axios$1 {
2771
2786
  // Set config.method
2772
2787
  config.method = (config.method || this.defaults.method || 'get').toLowerCase();
2773
2788
 
2774
- let contextHeaders;
2775
-
2776
2789
  // Flatten headers
2777
- contextHeaders = headers && utils.merge(
2790
+ let contextHeaders = headers && utils.merge(
2778
2791
  headers.common,
2779
2792
  headers[config.method]
2780
2793
  );
2781
2794
 
2782
- contextHeaders && utils.forEach(
2795
+ headers && utils.forEach(
2783
2796
  ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
2784
2797
  (method) => {
2785
2798
  delete headers[method];
@@ -3189,6 +3202,8 @@ axios.AxiosHeaders = AxiosHeaders$2;
3189
3202
 
3190
3203
  axios.formToJSON = thing => formDataToJSON(utils.isHTMLForm(thing) ? new FormData(thing) : thing);
3191
3204
 
3205
+ axios.getAdapter = adapters.getAdapter;
3206
+
3192
3207
  axios.HttpStatusCode = HttpStatusCode$2;
3193
3208
 
3194
3209
  axios.default = axios;
@@ -3214,8 +3229,9 @@ const {
3214
3229
  AxiosHeaders,
3215
3230
  HttpStatusCode,
3216
3231
  formToJSON,
3232
+ getAdapter,
3217
3233
  mergeConfig
3218
3234
  } = axios$1;
3219
3235
 
3220
- 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 };
3221
3237
  //# sourceMappingURL=axios.js.map