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.

package/dist/esm/axios.js CHANGED
@@ -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
  function bind(fn, thisArg) {
3
3
  return function wrap() {
4
4
  return fn.apply(thisArg, arguments);
@@ -2631,16 +2631,14 @@ const streamChunk = function* (chunk, chunkSize) {
2631
2631
  }
2632
2632
  };
2633
2633
 
2634
- const encoder = new TextEncoder();
2635
-
2636
- const readBytes = async function* (iterable, chunkSize) {
2634
+ const readBytes = async function* (iterable, chunkSize, encode) {
2637
2635
  for await (const chunk of iterable) {
2638
- yield* streamChunk(ArrayBuffer.isView(chunk) ? chunk : (await encoder.encode(String(chunk))), chunkSize);
2636
+ yield* streamChunk(ArrayBuffer.isView(chunk) ? chunk : (await encode(String(chunk))), chunkSize);
2639
2637
  }
2640
2638
  };
2641
2639
 
2642
- const trackStream = (stream, chunkSize, onProgress, onFinish) => {
2643
- const iterator = readBytes(stream, chunkSize);
2640
+ const trackStream = (stream, chunkSize, onProgress, onFinish, encode) => {
2641
+ const iterator = readBytes(stream, chunkSize, encode);
2644
2642
 
2645
2643
  let bytes = 0;
2646
2644
 
@@ -2681,6 +2679,12 @@ const fetchProgressDecorator = (total, fn) => {
2681
2679
  const isFetchSupported = typeof fetch !== 'undefined';
2682
2680
  const isReadableStreamSupported = isFetchSupported && typeof ReadableStream !== 'undefined';
2683
2681
 
2682
+ // used only inside the fetch adapter
2683
+ const encodeText = isFetchSupported && (typeof TextEncoder !== 'undefined' ?
2684
+ ((encoder) => (str) => encoder.encode(str))(new TextEncoder()) :
2685
+ async (str) => new Uint8Array(await new Response(str).arrayBuffer())
2686
+ );
2687
+
2684
2688
  const supportsRequestStream = isReadableStreamSupported && (() => {
2685
2689
  let duplexAccessed = false;
2686
2690
 
@@ -2741,7 +2745,7 @@ const getBodyLength = async (body) => {
2741
2745
  }
2742
2746
 
2743
2747
  if(utils$1.isString(body)) {
2744
- return (await new TextEncoder().encode(body)).byteLength;
2748
+ return (await encodeText(body)).byteLength;
2745
2749
  }
2746
2750
  };
2747
2751
 
@@ -2805,7 +2809,7 @@ const fetchAdapter = isFetchSupported && (async (config) => {
2805
2809
  data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, fetchProgressDecorator(
2806
2810
  requestContentLength,
2807
2811
  progressEventReducer(onUploadProgress)
2808
- ));
2812
+ ), null, encodeText);
2809
2813
  }
2810
2814
  }
2811
2815
 
@@ -2840,7 +2844,7 @@ const fetchAdapter = isFetchSupported && (async (config) => {
2840
2844
  trackStream(response.body, DEFAULT_CHUNK_SIZE, onDownloadProgress && fetchProgressDecorator(
2841
2845
  responseContentLength,
2842
2846
  progressEventReducer(onDownloadProgress, true)
2843
- ), isStreamResponse && onFinish),
2847
+ ), isStreamResponse && onFinish, encodeText),
2844
2848
  options
2845
2849
  );
2846
2850
  }
@@ -3026,7 +3030,7 @@ function dispatchRequest(config) {
3026
3030
  });
3027
3031
  }
3028
3032
 
3029
- const VERSION$1 = "1.7.0";
3033
+ const VERSION$1 = "1.7.1";
3030
3034
 
3031
3035
  const validators$1 = {};
3032
3036