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.

@@ -20,6 +20,12 @@ const fetchProgressDecorator = (total, fn) => {
20
20
  const isFetchSupported = typeof fetch !== 'undefined';
21
21
  const isReadableStreamSupported = isFetchSupported && typeof ReadableStream !== 'undefined';
22
22
 
23
+ // used only inside the fetch adapter
24
+ const encodeText = isFetchSupported && (typeof TextEncoder !== 'undefined' ?
25
+ ((encoder) => (str) => encoder.encode(str))(new TextEncoder()) :
26
+ async (str) => new Uint8Array(await new Response(str).arrayBuffer())
27
+ );
28
+
23
29
  const supportsRequestStream = isReadableStreamSupported && (() => {
24
30
  let duplexAccessed = false;
25
31
 
@@ -80,7 +86,7 @@ const getBodyLength = async (body) => {
80
86
  }
81
87
 
82
88
  if(utils.isString(body)) {
83
- return (await new TextEncoder().encode(body)).byteLength;
89
+ return (await encodeText(body)).byteLength;
84
90
  }
85
91
  }
86
92
 
@@ -144,7 +150,7 @@ export default isFetchSupported && (async (config) => {
144
150
  data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, fetchProgressDecorator(
145
151
  requestContentLength,
146
152
  progressEventReducer(onUploadProgress)
147
- ));
153
+ ), null, encodeText);
148
154
  }
149
155
  }
150
156
 
@@ -179,7 +185,7 @@ export default isFetchSupported && (async (config) => {
179
185
  trackStream(response.body, DEFAULT_CHUNK_SIZE, onDownloadProgress && fetchProgressDecorator(
180
186
  responseContentLength,
181
187
  progressEventReducer(onDownloadProgress, true)
182
- ), isStreamResponse && onFinish),
188
+ ), isStreamResponse && onFinish, encodeText),
183
189
  options
184
190
  );
185
191
  }
package/lib/env/data.js CHANGED
@@ -1 +1 @@
1
- export const VERSION = "1.7.0";
1
+ export const VERSION = "1.7.1";
@@ -1,4 +1,5 @@
1
1
 
2
+
2
3
  export const streamChunk = function* (chunk, chunkSize) {
3
4
  let len = chunk.byteLength;
4
5
 
@@ -17,16 +18,14 @@ export const streamChunk = function* (chunk, chunkSize) {
17
18
  }
18
19
  }
19
20
 
20
- const encoder = new TextEncoder();
21
-
22
- export const readBytes = async function* (iterable, chunkSize) {
21
+ export const readBytes = async function* (iterable, chunkSize, encode) {
23
22
  for await (const chunk of iterable) {
24
- yield* streamChunk(ArrayBuffer.isView(chunk) ? chunk : (await encoder.encode(String(chunk))), chunkSize);
23
+ yield* streamChunk(ArrayBuffer.isView(chunk) ? chunk : (await encode(String(chunk))), chunkSize);
25
24
  }
26
25
  }
27
26
 
28
- export const trackStream = (stream, chunkSize, onProgress, onFinish) => {
29
- const iterator = readBytes(stream, chunkSize);
27
+ export const trackStream = (stream, chunkSize, onProgress, onFinish, encode) => {
28
+ const iterator = readBytes(stream, chunkSize, encode);
30
29
 
31
30
  let bytes = 0;
32
31
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "axios",
3
- "version": "1.7.0",
3
+ "version": "1.7.1",
4
4
  "description": "Promise based HTTP client for the browser and node.js",
5
5
  "main": "index.js",
6
6
  "exports": {