axios 1.6.1 → 1.6.2

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.6.1 Copyright (c) 2023 Matt Zabriskie and contributors
1
+ // Axios v1.6.2 Copyright (c) 2023 Matt Zabriskie and contributors
2
2
  function bind(fn, thisArg) {
3
3
  return function wrap() {
4
4
  return fn.apply(thisArg, arguments);
@@ -1958,51 +1958,42 @@ function settle(resolve, reject, response) {
1958
1958
 
1959
1959
  const cookies = platform.hasStandardBrowserEnv ?
1960
1960
 
1961
- // Standard browser envs support document.cookie
1962
- (function standardBrowserEnv() {
1963
- return {
1964
- write: function write(name, value, expires, path, domain, secure) {
1965
- const cookie = [];
1966
- cookie.push(name + '=' + encodeURIComponent(value));
1961
+ // Standard browser envs support document.cookie
1962
+ {
1963
+ write(name, value, expires, path, domain, secure) {
1964
+ const cookie = [name + '=' + encodeURIComponent(value)];
1967
1965
 
1968
- if (utils$1.isNumber(expires)) {
1969
- cookie.push('expires=' + new Date(expires).toGMTString());
1970
- }
1966
+ utils$1.isNumber(expires) && cookie.push('expires=' + new Date(expires).toGMTString());
1971
1967
 
1972
- if (utils$1.isString(path)) {
1973
- cookie.push('path=' + path);
1974
- }
1968
+ utils$1.isString(path) && cookie.push('path=' + path);
1975
1969
 
1976
- if (utils$1.isString(domain)) {
1977
- cookie.push('domain=' + domain);
1978
- }
1970
+ utils$1.isString(domain) && cookie.push('domain=' + domain);
1979
1971
 
1980
- if (secure === true) {
1981
- cookie.push('secure');
1982
- }
1972
+ secure === true && cookie.push('secure');
1983
1973
 
1984
- document.cookie = cookie.join('; ');
1985
- },
1974
+ document.cookie = cookie.join('; ');
1975
+ },
1986
1976
 
1987
- read: function read(name) {
1988
- const match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
1989
- return (match ? decodeURIComponent(match[3]) : null);
1990
- },
1977
+ read(name) {
1978
+ const match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
1979
+ return (match ? decodeURIComponent(match[3]) : null);
1980
+ },
1991
1981
 
1992
- remove: function remove(name) {
1993
- this.write(name, '', Date.now() - 86400000);
1994
- }
1995
- };
1996
- })() :
1982
+ remove(name) {
1983
+ this.write(name, '', Date.now() - 86400000);
1984
+ }
1985
+ }
1997
1986
 
1998
- // Non standard browser env (web workers, react-native) lack needed support.
1999
- (function nonStandardBrowserEnv() {
2000
- return {
2001
- write: function write() {},
2002
- read: function read() { return null; },
2003
- remove: function remove() {}
2004
- };
2005
- })();
1987
+ :
1988
+
1989
+ // Non-standard browser env (web workers, react-native) lack needed support.
1990
+ {
1991
+ write() {},
1992
+ read() {
1993
+ return null;
1994
+ },
1995
+ remove() {}
1996
+ };
2006
1997
 
2007
1998
  /**
2008
1999
  * Determines whether the specified URL is absolute
@@ -2059,7 +2050,7 @@ const isURLSameOrigin = platform.hasStandardBrowserEnv ?
2059
2050
  let originURL;
2060
2051
 
2061
2052
  /**
2062
- * Parse a URL to discover it's components
2053
+ * Parse a URL to discover its components
2063
2054
  *
2064
2055
  * @param {String} url The URL to be parsed
2065
2056
  * @returns {Object}
@@ -2204,7 +2195,7 @@ const xhrAdapter = isXHRAdapterSupported && function (config) {
2204
2195
  return new Promise(function dispatchXhrRequest(resolve, reject) {
2205
2196
  let requestData = config.data;
2206
2197
  const requestHeaders = AxiosHeaders$2.from(config.headers).normalize();
2207
- const responseType = config.responseType;
2198
+ let {responseType, withXSRFToken} = config;
2208
2199
  let onCanceled;
2209
2200
  function done() {
2210
2201
  if (config.cancelToken) {
@@ -2340,13 +2331,16 @@ const xhrAdapter = isXHRAdapterSupported && function (config) {
2340
2331
  // Add xsrf header
2341
2332
  // This is only done if running in a standard browser environment.
2342
2333
  // Specifically not if we're in a web worker, or react-native.
2343
- if (platform.hasStandardBrowserEnv) {
2344
- // Add xsrf header
2345
- // regarding CVE-2023-45857 config.withCredentials condition was removed temporarily
2346
- const xsrfValue = isURLSameOrigin(fullPath) && config.xsrfCookieName && cookies.read(config.xsrfCookieName);
2334
+ if(platform.hasStandardBrowserEnv) {
2335
+ withXSRFToken && utils$1.isFunction(withXSRFToken) && (withXSRFToken = withXSRFToken(config));
2347
2336
 
2348
- if (xsrfValue) {
2349
- requestHeaders.set(config.xsrfHeaderName, xsrfValue);
2337
+ if (withXSRFToken || (withXSRFToken !== false && isURLSameOrigin(fullPath))) {
2338
+ // Add xsrf header
2339
+ const xsrfValue = config.xsrfHeaderName && config.xsrfCookieName && cookies.read(config.xsrfCookieName);
2340
+
2341
+ if (xsrfValue) {
2342
+ requestHeaders.set(config.xsrfHeaderName, xsrfValue);
2343
+ }
2350
2344
  }
2351
2345
  }
2352
2346
 
@@ -2629,6 +2623,7 @@ function mergeConfig$1(config1, config2) {
2629
2623
  timeout: defaultToConfig2,
2630
2624
  timeoutMessage: defaultToConfig2,
2631
2625
  withCredentials: defaultToConfig2,
2626
+ withXSRFToken: defaultToConfig2,
2632
2627
  adapter: defaultToConfig2,
2633
2628
  responseType: defaultToConfig2,
2634
2629
  xsrfCookieName: defaultToConfig2,
@@ -2658,7 +2653,7 @@ function mergeConfig$1(config1, config2) {
2658
2653
  return config;
2659
2654
  }
2660
2655
 
2661
- const VERSION$1 = "1.6.1";
2656
+ const VERSION$1 = "1.6.2";
2662
2657
 
2663
2658
  const validators$1 = {};
2664
2659