axios 1.3.3 → 1.3.4

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.3 Copyright (c) 2023 Matt Zabriskie and contributors
1
+ // Axios v1.3.4 Copyright (c) 2023 Matt Zabriskie and contributors
2
2
  'use strict';
3
3
 
4
4
  const FormData$1 = require('form-data');
@@ -1952,7 +1952,7 @@ function buildFullPath(baseURL, requestedURL) {
1952
1952
  return requestedURL;
1953
1953
  }
1954
1954
 
1955
- const VERSION = "1.3.3";
1955
+ const VERSION = "1.3.4";
1956
1956
 
1957
1957
  function parseProtocol(url) {
1958
1958
  const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
@@ -2514,15 +2514,39 @@ function setProxy(options, configProxy, location) {
2514
2514
 
2515
2515
  const isHttpAdapterSupported = typeof process !== 'undefined' && utils.kindOf(process) === 'process';
2516
2516
 
2517
+ // temporary hotfix
2518
+
2519
+ const wrapAsync = (asyncExecutor) => {
2520
+ return new Promise((resolve, reject) => {
2521
+ let onDone;
2522
+ let isDone;
2523
+
2524
+ const done = (value, isRejected) => {
2525
+ if (isDone) return;
2526
+ isDone = true;
2527
+ onDone && onDone(value, isRejected);
2528
+ };
2529
+
2530
+ const _resolve = (value) => {
2531
+ done(value);
2532
+ resolve(value);
2533
+ };
2534
+
2535
+ const _reject = (reason) => {
2536
+ done(reason, true);
2537
+ reject(reason);
2538
+ };
2539
+
2540
+ asyncExecutor(_resolve, _reject, (onDoneHandler) => (onDone = onDoneHandler)).catch(_reject);
2541
+ })
2542
+ };
2543
+
2517
2544
  /*eslint consistent-return:0*/
2518
2545
  const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
2519
- /*eslint no-async-promise-executor:0*/
2520
- return new Promise(async function dispatchHttpRequest(resolvePromise, rejectPromise) {
2521
- let data = config.data;
2522
- const responseType = config.responseType;
2523
- const responseEncoding = config.responseEncoding;
2546
+ return wrapAsync(async function dispatchHttpRequest(resolve, reject, onDone) {
2547
+ let {data} = config;
2548
+ const {responseType, responseEncoding} = config;
2524
2549
  const method = config.method.toUpperCase();
2525
- let isFinished;
2526
2550
  let isDone;
2527
2551
  let rejected = false;
2528
2552
  let req;
@@ -2530,10 +2554,7 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
2530
2554
  // temporary internal emitter until the AxiosRequest class will be implemented
2531
2555
  const emitter = new EventEmitter__default["default"]();
2532
2556
 
2533
- function onFinished() {
2534
- if (isFinished) return;
2535
- isFinished = true;
2536
-
2557
+ const onFinished = () => {
2537
2558
  if (config.cancelToken) {
2538
2559
  config.cancelToken.unsubscribe(abort);
2539
2560
  }
@@ -2543,28 +2564,15 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
2543
2564
  }
2544
2565
 
2545
2566
  emitter.removeAllListeners();
2546
- }
2547
-
2548
- function done(value, isRejected) {
2549
- if (isDone) return;
2567
+ };
2550
2568
 
2569
+ onDone((value, isRejected) => {
2551
2570
  isDone = true;
2552
-
2553
2571
  if (isRejected) {
2554
2572
  rejected = true;
2555
2573
  onFinished();
2556
2574
  }
2557
-
2558
- isRejected ? rejectPromise(value) : resolvePromise(value);
2559
- }
2560
-
2561
- const resolve = function resolve(value) {
2562
- done(value);
2563
- };
2564
-
2565
- const reject = function reject(value) {
2566
- done(value, true);
2567
- };
2575
+ });
2568
2576
 
2569
2577
  function abort(reason) {
2570
2578
  emitter.emit('abort', !reason || reason.type ? new CanceledError(null, config, req) : reason);