axios 1.3.0 → 1.3.2

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.0 Copyright (c) 2023 Matt Zabriskie and contributors
1
+ // Axios v1.3.2 Copyright (c) 2023 Matt Zabriskie and contributors
2
2
  'use strict';
3
3
 
4
4
  const FormData$1 = require('form-data');
@@ -6,6 +6,7 @@ const url = require('url');
6
6
  const proxyFromEnv = require('proxy-from-env');
7
7
  const http = require('http');
8
8
  const https = require('https');
9
+ const util = require('util');
9
10
  const followRedirects = require('follow-redirects');
10
11
  const zlib = require('zlib');
11
12
  const stream = require('stream');
@@ -17,6 +18,7 @@ const FormData__default = /*#__PURE__*/_interopDefaultLegacy(FormData$1);
17
18
  const url__default = /*#__PURE__*/_interopDefaultLegacy(url);
18
19
  const http__default = /*#__PURE__*/_interopDefaultLegacy(http);
19
20
  const https__default = /*#__PURE__*/_interopDefaultLegacy(https);
21
+ const util__default = /*#__PURE__*/_interopDefaultLegacy(util);
20
22
  const followRedirects__default = /*#__PURE__*/_interopDefaultLegacy(followRedirects);
21
23
  const zlib__default = /*#__PURE__*/_interopDefaultLegacy(zlib);
22
24
  const stream__default = /*#__PURE__*/_interopDefaultLegacy(stream);
@@ -978,7 +980,7 @@ function toFormData(obj, formData, options) {
978
980
  value = JSON.stringify(value);
979
981
  } else if (
980
982
  (utils.isArray(value) && isFlatArray(value)) ||
981
- (utils.isFileList(value) || utils.endsWith(key, '[]') && (arr = utils.toArray(value))
983
+ ((utils.isFileList(value) || utils.endsWith(key, '[]')) && (arr = utils.toArray(value))
982
984
  )) {
983
985
  // eslint-disable-next-line no-param-reassign
984
986
  key = removeBrackets(key);
@@ -1687,7 +1689,7 @@ class AxiosHeaders {
1687
1689
  if (header) {
1688
1690
  const key = utils.findKey(this, header);
1689
1691
 
1690
- return !!(key && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
1692
+ return !!(key && this[key] !== undefined && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
1691
1693
  }
1692
1694
 
1693
1695
  return false;
@@ -1946,7 +1948,7 @@ function buildFullPath(baseURL, requestedURL) {
1946
1948
  return requestedURL;
1947
1949
  }
1948
1950
 
1949
- const VERSION = "1.3.0";
1951
+ const VERSION = "1.3.2";
1950
1952
 
1951
1953
  function parseProtocol(url) {
1952
1954
  const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
@@ -2286,7 +2288,7 @@ const readBlob$1 = readBlob;
2286
2288
 
2287
2289
  const BOUNDARY_ALPHABET = utils.ALPHABET.ALPHA_DIGIT + '-_';
2288
2290
 
2289
- const textEncoder = new TextEncoder();
2291
+ const textEncoder = new util.TextEncoder();
2290
2292
 
2291
2293
  const CRLF = '\r\n';
2292
2294
  const CRLF_BYTES = textEncoder.encode(CRLF);
@@ -2510,7 +2512,8 @@ const isHttpAdapterSupported = typeof process !== 'undefined' && utils.kindOf(pr
2510
2512
 
2511
2513
  /*eslint consistent-return:0*/
2512
2514
  const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
2513
- return new Promise(function dispatchHttpRequest(resolvePromise, rejectPromise) {
2515
+ /*eslint no-async-promise-executor:0*/
2516
+ return new Promise(async function dispatchHttpRequest(resolvePromise, rejectPromise) {
2514
2517
  let data = config.data;
2515
2518
  const responseType = config.responseType;
2516
2519
  const responseEncoding = config.responseEncoding;
@@ -2574,7 +2577,7 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
2574
2577
 
2575
2578
  // Parse url
2576
2579
  const fullPath = buildFullPath(config.baseURL, config.url);
2577
- const parsed = new URL(fullPath);
2580
+ const parsed = new URL(fullPath, 'http://localhost');
2578
2581
  const protocol = parsed.protocol || supportedProtocols[0];
2579
2582
 
2580
2583
  if (protocol === 'data:') {
@@ -2601,7 +2604,7 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
2601
2604
  convertedData = convertedData.toString(responseEncoding);
2602
2605
 
2603
2606
  if (!responseEncoding || responseEncoding === 'utf8') {
2604
- data = utils.stripBOM(convertedData);
2607
+ convertedData = utils.stripBOM(convertedData);
2605
2608
  }
2606
2609
  } else if (responseType === 'stream') {
2607
2610
  convertedData = stream__default["default"].Readable.from(convertedData);
@@ -2651,9 +2654,14 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
2651
2654
  // support for https://www.npmjs.com/package/form-data api
2652
2655
  } else if (utils.isFormData(data) && utils.isFunction(data.getHeaders)) {
2653
2656
  headers.set(data.getHeaders());
2654
- if (utils.isFunction(data.getLengthSync)) { // check if the undocumented API exists
2655
- const knownLength = data.getLengthSync();
2656
- !utils.isUndefined(knownLength) && headers.setContentLength(knownLength, false);
2657
+
2658
+ if (!headers.hasContentLength()) {
2659
+ try {
2660
+ const knownLength = await util__default["default"].promisify(data.getLength).call(data);
2661
+ headers.setContentLength(knownLength);
2662
+ /*eslint no-empty:0*/
2663
+ } catch (e) {
2664
+ }
2657
2665
  }
2658
2666
  } else if (utils.isBlob(data)) {
2659
2667
  data.size && headers.setContentType(data.type || 'application/octet-stream');