axios 1.6.1 → 1.6.3

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.6.1 Copyright (c) 2023 Matt Zabriskie and contributors
1
+ // Axios v1.6.3 Copyright (c) 2023 Matt Zabriskie and contributors
2
2
  'use strict';
3
3
 
4
4
  const FormData$1 = require('form-data');
@@ -1998,7 +1998,7 @@ function isAbsoluteURL(url) {
1998
1998
  */
1999
1999
  function combineURLs(baseURL, relativeURL) {
2000
2000
  return relativeURL
2001
- ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
2001
+ ? baseURL.replace(/\/?\/$/, '') + '/' + relativeURL.replace(/^\/+/, '')
2002
2002
  : baseURL;
2003
2003
  }
2004
2004
 
@@ -2019,7 +2019,7 @@ function buildFullPath(baseURL, requestedURL) {
2019
2019
  return requestedURL;
2020
2020
  }
2021
2021
 
2022
- const VERSION = "1.6.1";
2022
+ const VERSION = "1.6.3";
2023
2023
 
2024
2024
  function parseProtocol(url) {
2025
2025
  const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
@@ -3157,51 +3157,42 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
3157
3157
 
3158
3158
  const cookies = platform.hasStandardBrowserEnv ?
3159
3159
 
3160
- // Standard browser envs support document.cookie
3161
- (function standardBrowserEnv() {
3162
- return {
3163
- write: function write(name, value, expires, path, domain, secure) {
3164
- const cookie = [];
3165
- cookie.push(name + '=' + encodeURIComponent(value));
3160
+ // Standard browser envs support document.cookie
3161
+ {
3162
+ write(name, value, expires, path, domain, secure) {
3163
+ const cookie = [name + '=' + encodeURIComponent(value)];
3166
3164
 
3167
- if (utils$1.isNumber(expires)) {
3168
- cookie.push('expires=' + new Date(expires).toGMTString());
3169
- }
3165
+ utils$1.isNumber(expires) && cookie.push('expires=' + new Date(expires).toGMTString());
3170
3166
 
3171
- if (utils$1.isString(path)) {
3172
- cookie.push('path=' + path);
3173
- }
3167
+ utils$1.isString(path) && cookie.push('path=' + path);
3174
3168
 
3175
- if (utils$1.isString(domain)) {
3176
- cookie.push('domain=' + domain);
3177
- }
3169
+ utils$1.isString(domain) && cookie.push('domain=' + domain);
3178
3170
 
3179
- if (secure === true) {
3180
- cookie.push('secure');
3181
- }
3171
+ secure === true && cookie.push('secure');
3182
3172
 
3183
- document.cookie = cookie.join('; ');
3184
- },
3173
+ document.cookie = cookie.join('; ');
3174
+ },
3185
3175
 
3186
- read: function read(name) {
3187
- const match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
3188
- return (match ? decodeURIComponent(match[3]) : null);
3189
- },
3176
+ read(name) {
3177
+ const match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
3178
+ return (match ? decodeURIComponent(match[3]) : null);
3179
+ },
3190
3180
 
3191
- remove: function remove(name) {
3192
- this.write(name, '', Date.now() - 86400000);
3193
- }
3194
- };
3195
- })() :
3181
+ remove(name) {
3182
+ this.write(name, '', Date.now() - 86400000);
3183
+ }
3184
+ }
3196
3185
 
3197
- // Non standard browser env (web workers, react-native) lack needed support.
3198
- (function nonStandardBrowserEnv() {
3199
- return {
3200
- write: function write() {},
3201
- read: function read() { return null; },
3202
- remove: function remove() {}
3203
- };
3204
- })();
3186
+ :
3187
+
3188
+ // Non-standard browser env (web workers, react-native) lack needed support.
3189
+ {
3190
+ write() {},
3191
+ read() {
3192
+ return null;
3193
+ },
3194
+ remove() {}
3195
+ };
3205
3196
 
3206
3197
  const isURLSameOrigin = platform.hasStandardBrowserEnv ?
3207
3198
 
@@ -3213,7 +3204,7 @@ const isURLSameOrigin = platform.hasStandardBrowserEnv ?
3213
3204
  let originURL;
3214
3205
 
3215
3206
  /**
3216
- * Parse a URL to discover it's components
3207
+ * Parse a URL to discover its components
3217
3208
  *
3218
3209
  * @param {String} url The URL to be parsed
3219
3210
  * @returns {Object}
@@ -3301,7 +3292,7 @@ const xhrAdapter = isXHRAdapterSupported && function (config) {
3301
3292
  return new Promise(function dispatchXhrRequest(resolve, reject) {
3302
3293
  let requestData = config.data;
3303
3294
  const requestHeaders = AxiosHeaders$1.from(config.headers).normalize();
3304
- const responseType = config.responseType;
3295
+ let {responseType, withXSRFToken} = config;
3305
3296
  let onCanceled;
3306
3297
  function done() {
3307
3298
  if (config.cancelToken) {
@@ -3437,13 +3428,16 @@ const xhrAdapter = isXHRAdapterSupported && function (config) {
3437
3428
  // Add xsrf header
3438
3429
  // This is only done if running in a standard browser environment.
3439
3430
  // Specifically not if we're in a web worker, or react-native.
3440
- if (platform.hasStandardBrowserEnv) {
3441
- // Add xsrf header
3442
- // regarding CVE-2023-45857 config.withCredentials condition was removed temporarily
3443
- const xsrfValue = isURLSameOrigin(fullPath) && config.xsrfCookieName && cookies.read(config.xsrfCookieName);
3431
+ if(platform.hasStandardBrowserEnv) {
3432
+ withXSRFToken && utils$1.isFunction(withXSRFToken) && (withXSRFToken = withXSRFToken(config));
3444
3433
 
3445
- if (xsrfValue) {
3446
- requestHeaders.set(config.xsrfHeaderName, xsrfValue);
3434
+ if (withXSRFToken || (withXSRFToken !== false && isURLSameOrigin(fullPath))) {
3435
+ // Add xsrf header
3436
+ const xsrfValue = config.xsrfHeaderName && config.xsrfCookieName && cookies.read(config.xsrfCookieName);
3437
+
3438
+ if (xsrfValue) {
3439
+ requestHeaders.set(config.xsrfHeaderName, xsrfValue);
3440
+ }
3447
3441
  }
3448
3442
  }
3449
3443
 
@@ -3726,6 +3720,7 @@ function mergeConfig(config1, config2) {
3726
3720
  timeout: defaultToConfig2,
3727
3721
  timeoutMessage: defaultToConfig2,
3728
3722
  withCredentials: defaultToConfig2,
3723
+ withXSRFToken: defaultToConfig2,
3729
3724
  adapter: defaultToConfig2,
3730
3725
  responseType: defaultToConfig2,
3731
3726
  xsrfCookieName: defaultToConfig2,