axios 1.6.6 → 1.6.8

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.6 Copyright (c) 2024 Matt Zabriskie and contributors
1
+ // Axios v1.6.8 Copyright (c) 2024 Matt Zabriskie and contributors
2
2
  'use strict';
3
3
 
4
4
  const FormData$1 = require('form-data');
@@ -10,7 +10,7 @@ const util = require('util');
10
10
  const followRedirects = require('follow-redirects');
11
11
  const zlib = require('zlib');
12
12
  const stream = require('stream');
13
- const EventEmitter = require('events');
13
+ const events = require('events');
14
14
 
15
15
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
16
16
 
@@ -22,7 +22,6 @@ const util__default = /*#__PURE__*/_interopDefaultLegacy(util);
22
22
  const followRedirects__default = /*#__PURE__*/_interopDefaultLegacy(followRedirects);
23
23
  const zlib__default = /*#__PURE__*/_interopDefaultLegacy(zlib);
24
24
  const stream__default = /*#__PURE__*/_interopDefaultLegacy(stream);
25
- const EventEmitter__default = /*#__PURE__*/_interopDefaultLegacy(EventEmitter);
26
25
 
27
26
  function bind(fn, thisArg) {
28
27
  return function wrap() {
@@ -1454,9 +1453,6 @@ const defaults = {
1454
1453
  const isFormData = utils$1.isFormData(data);
1455
1454
 
1456
1455
  if (isFormData) {
1457
- if (!hasJSONContentType) {
1458
- return data;
1459
- }
1460
1456
  return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
1461
1457
  }
1462
1458
 
@@ -2022,7 +2018,7 @@ function buildFullPath(baseURL, requestedURL) {
2022
2018
  return requestedURL;
2023
2019
  }
2024
2020
 
2025
- const VERSION = "1.6.6";
2021
+ const VERSION = "1.6.8";
2026
2022
 
2027
2023
  function parseProtocol(url) {
2028
2024
  const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
@@ -2665,7 +2661,7 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
2665
2661
  }
2666
2662
 
2667
2663
  // temporary internal emitter until the AxiosRequest class will be implemented
2668
- const emitter = new EventEmitter__default["default"]();
2664
+ const emitter = new events.EventEmitter();
2669
2665
 
2670
2666
  const onFinished = () => {
2671
2667
  if (config.cancelToken) {
@@ -3655,7 +3651,7 @@ function dispatchRequest(config) {
3655
3651
  });
3656
3652
  }
3657
3653
 
3658
- const headersToObject = (thing) => thing instanceof AxiosHeaders$1 ? thing.toJSON() : thing;
3654
+ const headersToObject = (thing) => thing instanceof AxiosHeaders$1 ? { ...thing } : thing;
3659
3655
 
3660
3656
  /**
3661
3657
  * Config-specific merge-function which creates a new config-object
@@ -3874,17 +3870,20 @@ class Axios {
3874
3870
  try {
3875
3871
  return await this._request(configOrUrl, config);
3876
3872
  } catch (err) {
3877
- const dummy = {};
3878
- if (Error.captureStackTrace) {
3879
- Error.captureStackTrace(dummy);
3880
- } else {
3881
- dummy.stack = new Error().stack;
3882
- }
3883
- // slice off the Error: ... line
3884
- dummy.stack = dummy.stack.replace(/^.+\n/, '');
3885
- // match without the 2 top stack lines
3886
- if (!err.stack.endsWith(dummy.stack.replace(/^.+\n.+\n/, ''))) {
3887
- err.stack += '\n' + dummy.stack;
3873
+ if (err instanceof Error) {
3874
+ let dummy;
3875
+
3876
+ Error.captureStackTrace ? Error.captureStackTrace(dummy = {}) : (dummy = new Error());
3877
+
3878
+ // slice off the Error: ... line
3879
+ const stack = dummy.stack ? dummy.stack.replace(/^.+\n/, '') : '';
3880
+
3881
+ if (!err.stack) {
3882
+ err.stack = stack;
3883
+ // match without the 2 top stack lines
3884
+ } else if (stack && !String(err.stack).endsWith(stack.replace(/^.+\n.+\n/, ''))) {
3885
+ err.stack += '\n' + stack;
3886
+ }
3888
3887
  }
3889
3888
 
3890
3889
  throw err;