axios 1.7.0 → 1.7.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.7.0 Copyright (c) 2024 Matt Zabriskie and contributors
1
+ // Axios v1.7.2 Copyright (c) 2024 Matt Zabriskie and contributors
2
2
  'use strict';
3
3
 
4
4
  const FormData$1 = require('form-data');
@@ -2035,7 +2035,7 @@ function buildFullPath(baseURL, requestedURL) {
2035
2035
  return requestedURL;
2036
2036
  }
2037
2037
 
2038
- const VERSION = "1.7.0";
2038
+ const VERSION = "1.7.2";
2039
2039
 
2040
2040
  function parseProtocol(url) {
2041
2041
  const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
@@ -3702,16 +3702,14 @@ const streamChunk = function* (chunk, chunkSize) {
3702
3702
  }
3703
3703
  };
3704
3704
 
3705
- const encoder = new TextEncoder();
3706
-
3707
- const readBytes = async function* (iterable, chunkSize) {
3705
+ const readBytes = async function* (iterable, chunkSize, encode) {
3708
3706
  for await (const chunk of iterable) {
3709
- yield* streamChunk(ArrayBuffer.isView(chunk) ? chunk : (await encoder.encode(String(chunk))), chunkSize);
3707
+ yield* streamChunk(ArrayBuffer.isView(chunk) ? chunk : (await encode(String(chunk))), chunkSize);
3710
3708
  }
3711
3709
  };
3712
3710
 
3713
- const trackStream = (stream, chunkSize, onProgress, onFinish) => {
3714
- const iterator = readBytes(stream, chunkSize);
3711
+ const trackStream = (stream, chunkSize, onProgress, onFinish, encode) => {
3712
+ const iterator = readBytes(stream, chunkSize, encode);
3715
3713
 
3716
3714
  let bytes = 0;
3717
3715
 
@@ -3749,8 +3747,14 @@ const fetchProgressDecorator = (total, fn) => {
3749
3747
  }));
3750
3748
  };
3751
3749
 
3752
- const isFetchSupported = typeof fetch !== 'undefined';
3753
- const isReadableStreamSupported = isFetchSupported && typeof ReadableStream !== 'undefined';
3750
+ const isFetchSupported = typeof fetch === 'function' && typeof Request === 'function' && typeof Response === 'function';
3751
+ const isReadableStreamSupported = isFetchSupported && typeof ReadableStream === 'function';
3752
+
3753
+ // used only inside the fetch adapter
3754
+ const encodeText = isFetchSupported && (typeof TextEncoder === 'function' ?
3755
+ ((encoder) => (str) => encoder.encode(str))(new TextEncoder()) :
3756
+ async (str) => new Uint8Array(await new Response(str).arrayBuffer())
3757
+ );
3754
3758
 
3755
3759
  const supportsRequestStream = isReadableStreamSupported && (() => {
3756
3760
  let duplexAccessed = false;
@@ -3812,7 +3816,7 @@ const getBodyLength = async (body) => {
3812
3816
  }
3813
3817
 
3814
3818
  if(utils$1.isString(body)) {
3815
- return (await new TextEncoder().encode(body)).byteLength;
3819
+ return (await encodeText(body)).byteLength;
3816
3820
  }
3817
3821
  };
3818
3822
 
@@ -3876,7 +3880,7 @@ const fetchAdapter = isFetchSupported && (async (config) => {
3876
3880
  data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, fetchProgressDecorator(
3877
3881
  requestContentLength,
3878
3882
  progressEventReducer(onUploadProgress)
3879
- ));
3883
+ ), null, encodeText);
3880
3884
  }
3881
3885
  }
3882
3886
 
@@ -3911,7 +3915,7 @@ const fetchAdapter = isFetchSupported && (async (config) => {
3911
3915
  trackStream(response.body, DEFAULT_CHUNK_SIZE, onDownloadProgress && fetchProgressDecorator(
3912
3916
  responseContentLength,
3913
3917
  progressEventReducer(onDownloadProgress, true)
3914
- ), isStreamResponse && onFinish),
3918
+ ), isStreamResponse && onFinish, encodeText),
3915
3919
  options
3916
3920
  );
3917
3921
  }