axios 1.7.4 → 1.7.5

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.4 Copyright (c) 2024 Matt Zabriskie and contributors
1
+ // Axios v1.7.5 Copyright (c) 2024 Matt Zabriskie and contributors
2
2
  'use strict';
3
3
 
4
4
  const FormData$1 = require('form-data');
@@ -811,7 +811,10 @@ function AxiosError(message, code, config, request, response) {
811
811
  code && (this.code = code);
812
812
  config && (this.config = config);
813
813
  request && (this.request = request);
814
- response && (this.response = response);
814
+ if (response) {
815
+ this.response = response;
816
+ this.status = response.status ? response.status : null;
817
+ }
815
818
  }
816
819
 
817
820
  utils$1.inherits(AxiosError, Error, {
@@ -831,7 +834,7 @@ utils$1.inherits(AxiosError, Error, {
831
834
  // Axios
832
835
  config: utils$1.toJSONObject(this.config),
833
836
  code: this.code,
834
- status: this.response && this.response.status ? this.response.status : null
837
+ status: this.status
835
838
  };
836
839
  }
837
840
  });
@@ -1292,6 +1295,8 @@ const platform$1 = {
1292
1295
 
1293
1296
  const hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'undefined';
1294
1297
 
1298
+ const _navigator = typeof navigator === 'object' && navigator || undefined;
1299
+
1295
1300
  /**
1296
1301
  * Determine if we're running in a standard browser environment
1297
1302
  *
@@ -1309,10 +1314,8 @@ const hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'unde
1309
1314
  *
1310
1315
  * @returns {boolean}
1311
1316
  */
1312
- const hasStandardBrowserEnv = (
1313
- (product) => {
1314
- return hasBrowserEnv && ['ReactNative', 'NativeScript', 'NS'].indexOf(product) < 0
1315
- })(typeof navigator !== 'undefined' && navigator.product);
1317
+ const hasStandardBrowserEnv = hasBrowserEnv &&
1318
+ (!_navigator || ['ReactNative', 'NativeScript', 'NS'].indexOf(_navigator.product) < 0);
1316
1319
 
1317
1320
  /**
1318
1321
  * Determine if we're running in a standard browser webWorker environment
@@ -1339,6 +1342,7 @@ const utils = /*#__PURE__*/Object.freeze({
1339
1342
  hasBrowserEnv: hasBrowserEnv,
1340
1343
  hasStandardBrowserWebWorkerEnv: hasStandardBrowserWebWorkerEnv,
1341
1344
  hasStandardBrowserEnv: hasStandardBrowserEnv,
1345
+ navigator: _navigator,
1342
1346
  origin: origin
1343
1347
  });
1344
1348
 
@@ -2067,7 +2071,7 @@ function buildFullPath(baseURL, requestedURL) {
2067
2071
  return requestedURL;
2068
2072
  }
2069
2073
 
2070
- const VERSION = "1.7.4";
2074
+ const VERSION = "1.7.5";
2071
2075
 
2072
2076
  function parseProtocol(url) {
2073
2077
  const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
@@ -2763,7 +2767,7 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
2763
2767
 
2764
2768
  // Parse url
2765
2769
  const fullPath = buildFullPath(config.baseURL, config.url);
2766
- const parsed = new URL(fullPath, utils$1.hasBrowserEnv ? platform.origin : undefined);
2770
+ const parsed = new URL(fullPath, platform.hasBrowserEnv ? platform.origin : undefined);
2767
2771
  const protocol = parsed.protocol || supportedProtocols[0];
2768
2772
 
2769
2773
  if (protocol === 'data:') {
@@ -3229,7 +3233,7 @@ const isURLSameOrigin = platform.hasStandardBrowserEnv ?
3229
3233
  // Standard browser envs have full support of the APIs needed to test
3230
3234
  // whether the request URL is of the same origin as current location.
3231
3235
  (function standardBrowserEnv() {
3232
- const msie = /(msie|trident)/i.test(navigator.userAgent);
3236
+ const msie = platform.navigator && /(msie|trident)/i.test(platform.navigator.userAgent);
3233
3237
  const urlParsingNode = document.createElement('a');
3234
3238
  let originURL;
3235
3239
 
@@ -3921,6 +3925,9 @@ const fetchAdapter = isFetchSupported && (async (config) => {
3921
3925
  withCredentials = withCredentials ? 'include' : 'omit';
3922
3926
  }
3923
3927
 
3928
+ // Cloudflare Workers throws when credentials are defined
3929
+ // see https://github.com/cloudflare/workerd/issues/902
3930
+ const isCredentialsSupported = "credentials" in Request.prototype;
3924
3931
  request = new Request(url, {
3925
3932
  ...fetchOptions,
3926
3933
  signal: composedSignal,
@@ -3928,7 +3935,7 @@ const fetchAdapter = isFetchSupported && (async (config) => {
3928
3935
  headers: headers.normalize().toJSON(),
3929
3936
  body: data,
3930
3937
  duplex: "half",
3931
- credentials: withCredentials
3938
+ credentials: isCredentialsSupported ? withCredentials : undefined
3932
3939
  });
3933
3940
 
3934
3941
  let response = await fetch(request);