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.

@@ -155,6 +155,9 @@ export default isFetchSupported && (async (config) => {
155
155
  withCredentials = withCredentials ? 'include' : 'omit';
156
156
  }
157
157
 
158
+ // Cloudflare Workers throws when credentials are defined
159
+ // see https://github.com/cloudflare/workerd/issues/902
160
+ const isCredentialsSupported = "credentials" in Request.prototype;
158
161
  request = new Request(url, {
159
162
  ...fetchOptions,
160
163
  signal: composedSignal,
@@ -162,7 +165,7 @@ export default isFetchSupported && (async (config) => {
162
165
  headers: headers.normalize().toJSON(),
163
166
  body: data,
164
167
  duplex: "half",
165
- credentials: withCredentials
168
+ credentials: isCredentialsSupported ? withCredentials : undefined
166
169
  });
167
170
 
168
171
  let response = await fetch(request);
@@ -229,7 +229,7 @@ export default isHttpAdapterSupported && function httpAdapter(config) {
229
229
 
230
230
  // Parse url
231
231
  const fullPath = buildFullPath(config.baseURL, config.url);
232
- const parsed = new URL(fullPath, utils.hasBrowserEnv ? platform.origin : undefined);
232
+ const parsed = new URL(fullPath, platform.hasBrowserEnv ? platform.origin : undefined);
233
233
  const protocol = parsed.protocol || supportedProtocols[0];
234
234
 
235
235
  if (protocol === 'data:') {
@@ -27,7 +27,10 @@ function AxiosError(message, code, config, request, response) {
27
27
  code && (this.code = code);
28
28
  config && (this.config = config);
29
29
  request && (this.request = request);
30
- response && (this.response = response);
30
+ if (response) {
31
+ this.response = response;
32
+ this.status = response.status ? response.status : null;
33
+ }
31
34
  }
32
35
 
33
36
  utils.inherits(AxiosError, Error, {
@@ -47,7 +50,7 @@ utils.inherits(AxiosError, Error, {
47
50
  // Axios
48
51
  config: utils.toJSONObject(this.config),
49
52
  code: this.code,
50
- status: this.response && this.response.status ? this.response.status : null
53
+ status: this.status
51
54
  };
52
55
  }
53
56
  });
package/lib/env/data.js CHANGED
@@ -1 +1 @@
1
- export const VERSION = "1.7.4";
1
+ export const VERSION = "1.7.5";
@@ -8,7 +8,7 @@ export default platform.hasStandardBrowserEnv ?
8
8
  // Standard browser envs have full support of the APIs needed to test
9
9
  // whether the request URL is of the same origin as current location.
10
10
  (function standardBrowserEnv() {
11
- const msie = /(msie|trident)/i.test(navigator.userAgent);
11
+ const msie = platform.navigator && /(msie|trident)/i.test(platform.navigator.userAgent);
12
12
  const urlParsingNode = document.createElement('a');
13
13
  let originURL;
14
14
 
@@ -1,5 +1,7 @@
1
1
  const hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'undefined';
2
2
 
3
+ const _navigator = typeof navigator === 'object' && navigator || undefined;
4
+
3
5
  /**
4
6
  * Determine if we're running in a standard browser environment
5
7
  *
@@ -17,10 +19,8 @@ const hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'unde
17
19
  *
18
20
  * @returns {boolean}
19
21
  */
20
- const hasStandardBrowserEnv = (
21
- (product) => {
22
- return hasBrowserEnv && ['ReactNative', 'NativeScript', 'NS'].indexOf(product) < 0
23
- })(typeof navigator !== 'undefined' && navigator.product);
22
+ const hasStandardBrowserEnv = hasBrowserEnv &&
23
+ (!_navigator || ['ReactNative', 'NativeScript', 'NS'].indexOf(_navigator.product) < 0);
24
24
 
25
25
  /**
26
26
  * Determine if we're running in a standard browser webWorker environment
@@ -46,5 +46,6 @@ export {
46
46
  hasBrowserEnv,
47
47
  hasStandardBrowserWebWorkerEnv,
48
48
  hasStandardBrowserEnv,
49
+ _navigator as navigator,
49
50
  origin
50
51
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "axios",
3
- "version": "1.7.4",
3
+ "version": "1.7.5",
4
4
  "description": "Promise based HTTP client for the browser and node.js",
5
5
  "main": "index.js",
6
6
  "exports": {