axios 1.7.6 → 1.7.7

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.6 Copyright (c) 2024 Matt Zabriskie and contributors
1
+ // Axios v1.7.7 Copyright (c) 2024 Matt Zabriskie and contributors
2
2
  'use strict';
3
3
 
4
4
  const FormData$1 = require('form-data');
@@ -2071,7 +2071,7 @@ function buildFullPath(baseURL, requestedURL) {
2071
2071
  return requestedURL;
2072
2072
  }
2073
2073
 
2074
- const VERSION = "1.7.6";
2074
+ const VERSION = "1.7.7";
2075
2075
 
2076
2076
  function parseProtocol(url) {
2077
2077
  const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
@@ -2963,7 +2963,7 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
2963
2963
  if (config.socketPath) {
2964
2964
  options.socketPath = config.socketPath;
2965
2965
  } else {
2966
- options.hostname = parsed.hostname;
2966
+ options.hostname = parsed.hostname.startsWith("[") ? parsed.hostname.slice(1, -1) : parsed.hostname;
2967
2967
  options.port = parsed.port;
2968
2968
  setProxy(options, config.proxy, protocol + '//' + parsed.hostname + (parsed.port ? ':' + parsed.port : '') + options.path);
2969
2969
  }
@@ -3730,14 +3730,34 @@ const streamChunk = function* (chunk, chunkSize) {
3730
3730
  }
3731
3731
  };
3732
3732
 
3733
- const readBytes = async function* (iterable, chunkSize, encode) {
3734
- for await (const chunk of iterable) {
3735
- yield* streamChunk(ArrayBuffer.isView(chunk) ? chunk : (await encode(String(chunk))), chunkSize);
3733
+ const readBytes = async function* (iterable, chunkSize) {
3734
+ for await (const chunk of readStream(iterable)) {
3735
+ yield* streamChunk(chunk, chunkSize);
3736
3736
  }
3737
3737
  };
3738
3738
 
3739
- const trackStream = (stream, chunkSize, onProgress, onFinish, encode) => {
3740
- const iterator = readBytes(stream, chunkSize, encode);
3739
+ const readStream = async function* (stream) {
3740
+ if (stream[Symbol.asyncIterator]) {
3741
+ yield* stream;
3742
+ return;
3743
+ }
3744
+
3745
+ const reader = stream.getReader();
3746
+ try {
3747
+ for (;;) {
3748
+ const {done, value} = await reader.read();
3749
+ if (done) {
3750
+ break;
3751
+ }
3752
+ yield value;
3753
+ }
3754
+ } finally {
3755
+ await reader.cancel();
3756
+ }
3757
+ };
3758
+
3759
+ const trackStream = (stream, chunkSize, onProgress, onFinish) => {
3760
+ const iterator = readBytes(stream, chunkSize);
3741
3761
 
3742
3762
  let bytes = 0;
3743
3763
  let done;
@@ -3917,7 +3937,7 @@ const fetchAdapter = isFetchSupported && (async (config) => {
3917
3937
  progressEventReducer(asyncDecorator(onUploadProgress))
3918
3938
  );
3919
3939
 
3920
- data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush, encodeText);
3940
+ data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush);
3921
3941
  }
3922
3942
  }
3923
3943
 
@@ -3960,7 +3980,7 @@ const fetchAdapter = isFetchSupported && (async (config) => {
3960
3980
  trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
3961
3981
  flush && flush();
3962
3982
  unsubscribe && unsubscribe();
3963
- }, encodeText),
3983
+ }),
3964
3984
  options
3965
3985
  );
3966
3986
  }