axios 1.3.3 → 1.3.5

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.5 Copyright (c) 2023 Matt Zabriskie and contributors
2
2
  'use strict';
3
3
 
4
4
  const FormData$1 = require('form-data');
@@ -1577,9 +1577,7 @@ function parseTokens(str) {
1577
1577
  return tokens;
1578
1578
  }
1579
1579
 
1580
- function isValidHeaderName(str) {
1581
- return /^[-_a-zA-Z]+$/.test(str.trim());
1582
- }
1580
+ const isValidHeaderName = (str) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
1583
1581
 
1584
1582
  function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
1585
1583
  if (utils.isFunction(filter)) {
@@ -1952,7 +1950,7 @@ function buildFullPath(baseURL, requestedURL) {
1952
1950
  return requestedURL;
1953
1951
  }
1954
1952
 
1955
- const VERSION = "1.3.3";
1953
+ const VERSION = "1.3.5";
1956
1954
 
1957
1955
  function parseProtocol(url) {
1958
1956
  const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
@@ -2514,15 +2512,39 @@ function setProxy(options, configProxy, location) {
2514
2512
 
2515
2513
  const isHttpAdapterSupported = typeof process !== 'undefined' && utils.kindOf(process) === 'process';
2516
2514
 
2515
+ // temporary hotfix
2516
+
2517
+ const wrapAsync = (asyncExecutor) => {
2518
+ return new Promise((resolve, reject) => {
2519
+ let onDone;
2520
+ let isDone;
2521
+
2522
+ const done = (value, isRejected) => {
2523
+ if (isDone) return;
2524
+ isDone = true;
2525
+ onDone && onDone(value, isRejected);
2526
+ };
2527
+
2528
+ const _resolve = (value) => {
2529
+ done(value);
2530
+ resolve(value);
2531
+ };
2532
+
2533
+ const _reject = (reason) => {
2534
+ done(reason, true);
2535
+ reject(reason);
2536
+ };
2537
+
2538
+ asyncExecutor(_resolve, _reject, (onDoneHandler) => (onDone = onDoneHandler)).catch(_reject);
2539
+ })
2540
+ };
2541
+
2517
2542
  /*eslint consistent-return:0*/
2518
2543
  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;
2544
+ return wrapAsync(async function dispatchHttpRequest(resolve, reject, onDone) {
2545
+ let {data} = config;
2546
+ const {responseType, responseEncoding} = config;
2524
2547
  const method = config.method.toUpperCase();
2525
- let isFinished;
2526
2548
  let isDone;
2527
2549
  let rejected = false;
2528
2550
  let req;
@@ -2530,10 +2552,7 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
2530
2552
  // temporary internal emitter until the AxiosRequest class will be implemented
2531
2553
  const emitter = new EventEmitter__default["default"]();
2532
2554
 
2533
- function onFinished() {
2534
- if (isFinished) return;
2535
- isFinished = true;
2536
-
2555
+ const onFinished = () => {
2537
2556
  if (config.cancelToken) {
2538
2557
  config.cancelToken.unsubscribe(abort);
2539
2558
  }
@@ -2543,28 +2562,15 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
2543
2562
  }
2544
2563
 
2545
2564
  emitter.removeAllListeners();
2546
- }
2547
-
2548
- function done(value, isRejected) {
2549
- if (isDone) return;
2565
+ };
2550
2566
 
2567
+ onDone((value, isRejected) => {
2551
2568
  isDone = true;
2552
-
2553
2569
  if (isRejected) {
2554
2570
  rejected = true;
2555
2571
  onFinished();
2556
2572
  }
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
- };
2573
+ });
2568
2574
 
2569
2575
  function abort(reason) {
2570
2576
  emitter.emit('abort', !reason || reason.type ? new CanceledError(null, config, req) : reason);
@@ -3746,11 +3752,17 @@ class Axios {
3746
3752
  }, false);
3747
3753
  }
3748
3754
 
3749
- if (paramsSerializer !== undefined) {
3750
- validator.assertOptions(paramsSerializer, {
3751
- encode: validators.function,
3752
- serialize: validators.function
3753
- }, true);
3755
+ if (paramsSerializer != null) {
3756
+ if (utils.isFunction(paramsSerializer)) {
3757
+ config.paramsSerializer = {
3758
+ serialize: paramsSerializer
3759
+ };
3760
+ } else {
3761
+ validator.assertOptions(paramsSerializer, {
3762
+ encode: validators.function,
3763
+ serialize: validators.function
3764
+ }, true);
3765
+ }
3754
3766
  }
3755
3767
 
3756
3768
  // Set config.method