axios 1.6.5 → 1.6.7

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.6.5 Copyright (c) 2024 Matt Zabriskie and contributors
1
+ // Axios v1.6.7 Copyright (c) 2024 Matt Zabriskie and contributors
2
2
  'use strict';
3
3
 
4
4
  const FormData$1 = require('form-data');
@@ -1454,9 +1454,6 @@ const defaults = {
1454
1454
  const isFormData = utils$1.isFormData(data);
1455
1455
 
1456
1456
  if (isFormData) {
1457
- if (!hasJSONContentType) {
1458
- return data;
1459
- }
1460
1457
  return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
1461
1458
  }
1462
1459
 
@@ -2022,7 +2019,7 @@ function buildFullPath(baseURL, requestedURL) {
2022
2019
  return requestedURL;
2023
2020
  }
2024
2021
 
2025
- const VERSION = "1.6.5";
2022
+ const VERSION = "1.6.7";
2026
2023
 
2027
2024
  function parseProtocol(url) {
2028
2025
  const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
@@ -2535,12 +2532,12 @@ const supportedProtocols = platform.protocols.map(protocol => {
2535
2532
  *
2536
2533
  * @returns {Object<string, any>}
2537
2534
  */
2538
- function dispatchBeforeRedirect(options) {
2535
+ function dispatchBeforeRedirect(options, responseDetails) {
2539
2536
  if (options.beforeRedirects.proxy) {
2540
2537
  options.beforeRedirects.proxy(options);
2541
2538
  }
2542
2539
  if (options.beforeRedirects.config) {
2543
- options.beforeRedirects.config(options);
2540
+ options.beforeRedirects.config(options, responseDetails);
2544
2541
  }
2545
2542
  }
2546
2543
 
@@ -3870,7 +3867,31 @@ class Axios {
3870
3867
  *
3871
3868
  * @returns {Promise} The Promise to be fulfilled
3872
3869
  */
3873
- request(configOrUrl, config) {
3870
+ async request(configOrUrl, config) {
3871
+ try {
3872
+ return await this._request(configOrUrl, config);
3873
+ } catch (err) {
3874
+ if (err instanceof Error) {
3875
+ let dummy;
3876
+
3877
+ Error.captureStackTrace ? Error.captureStackTrace(dummy = {}) : (dummy = new Error());
3878
+
3879
+ // slice off the Error: ... line
3880
+ const stack = dummy.stack ? dummy.stack.replace(/^.+\n/, '') : '';
3881
+
3882
+ if (!err.stack) {
3883
+ err.stack = stack;
3884
+ // match without the 2 top stack lines
3885
+ } else if (stack && !String(err.stack).endsWith(stack.replace(/^.+\n.+\n/, ''))) {
3886
+ err.stack += '\n' + stack;
3887
+ }
3888
+ }
3889
+
3890
+ throw err;
3891
+ }
3892
+ }
3893
+
3894
+ _request(configOrUrl, config) {
3874
3895
  /*eslint no-param-reassign:0*/
3875
3896
  // Allow for axios('example/url'[, config]) a la fetch API
3876
3897
  if (typeof configOrUrl === 'string') {