axios 1.7.0 → 1.7.1

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.1 Copyright (c) 2024 Matt Zabriskie and contributors
2
2
  'use strict';
3
3
 
4
4
  function bind(fn, thisArg) {
@@ -2633,16 +2633,14 @@ const streamChunk = function* (chunk, chunkSize) {
2633
2633
  }
2634
2634
  };
2635
2635
 
2636
- const encoder = new TextEncoder();
2637
-
2638
- const readBytes = async function* (iterable, chunkSize) {
2636
+ const readBytes = async function* (iterable, chunkSize, encode) {
2639
2637
  for await (const chunk of iterable) {
2640
- yield* streamChunk(ArrayBuffer.isView(chunk) ? chunk : (await encoder.encode(String(chunk))), chunkSize);
2638
+ yield* streamChunk(ArrayBuffer.isView(chunk) ? chunk : (await encode(String(chunk))), chunkSize);
2641
2639
  }
2642
2640
  };
2643
2641
 
2644
- const trackStream = (stream, chunkSize, onProgress, onFinish) => {
2645
- const iterator = readBytes(stream, chunkSize);
2642
+ const trackStream = (stream, chunkSize, onProgress, onFinish, encode) => {
2643
+ const iterator = readBytes(stream, chunkSize, encode);
2646
2644
 
2647
2645
  let bytes = 0;
2648
2646
 
@@ -2683,6 +2681,12 @@ const fetchProgressDecorator = (total, fn) => {
2683
2681
  const isFetchSupported = typeof fetch !== 'undefined';
2684
2682
  const isReadableStreamSupported = isFetchSupported && typeof ReadableStream !== 'undefined';
2685
2683
 
2684
+ // used only inside the fetch adapter
2685
+ const encodeText = isFetchSupported && (typeof TextEncoder !== 'undefined' ?
2686
+ ((encoder) => (str) => encoder.encode(str))(new TextEncoder()) :
2687
+ async (str) => new Uint8Array(await new Response(str).arrayBuffer())
2688
+ );
2689
+
2686
2690
  const supportsRequestStream = isReadableStreamSupported && (() => {
2687
2691
  let duplexAccessed = false;
2688
2692
 
@@ -2743,7 +2747,7 @@ const getBodyLength = async (body) => {
2743
2747
  }
2744
2748
 
2745
2749
  if(utils$1.isString(body)) {
2746
- return (await new TextEncoder().encode(body)).byteLength;
2750
+ return (await encodeText(body)).byteLength;
2747
2751
  }
2748
2752
  };
2749
2753
 
@@ -2807,7 +2811,7 @@ var fetchAdapter = isFetchSupported && (async (config) => {
2807
2811
  data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, fetchProgressDecorator(
2808
2812
  requestContentLength,
2809
2813
  progressEventReducer(onUploadProgress)
2810
- ));
2814
+ ), null, encodeText);
2811
2815
  }
2812
2816
  }
2813
2817
 
@@ -2842,7 +2846,7 @@ var fetchAdapter = isFetchSupported && (async (config) => {
2842
2846
  trackStream(response.body, DEFAULT_CHUNK_SIZE, onDownloadProgress && fetchProgressDecorator(
2843
2847
  responseContentLength,
2844
2848
  progressEventReducer(onDownloadProgress, true)
2845
- ), isStreamResponse && onFinish),
2849
+ ), isStreamResponse && onFinish, encodeText),
2846
2850
  options
2847
2851
  );
2848
2852
  }
@@ -3028,7 +3032,7 @@ function dispatchRequest(config) {
3028
3032
  });
3029
3033
  }
3030
3034
 
3031
- const VERSION = "1.7.0";
3035
+ const VERSION = "1.7.1";
3032
3036
 
3033
3037
  const validators$1 = {};
3034
3038