axios 1.7.7 → 1.7.8

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.7 Copyright (c) 2024 Matt Zabriskie and contributors
1
+ // Axios v1.7.8 Copyright (c) 2024 Matt Zabriskie and contributors
2
2
  'use strict';
3
3
 
4
4
  const FormData$1 = require('form-data');
@@ -16,6 +16,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
16
16
 
17
17
  const FormData__default = /*#__PURE__*/_interopDefaultLegacy(FormData$1);
18
18
  const url__default = /*#__PURE__*/_interopDefaultLegacy(url);
19
+ const proxyFromEnv__default = /*#__PURE__*/_interopDefaultLegacy(proxyFromEnv);
19
20
  const http__default = /*#__PURE__*/_interopDefaultLegacy(http);
20
21
  const https__default = /*#__PURE__*/_interopDefaultLegacy(https);
21
22
  const util__default = /*#__PURE__*/_interopDefaultLegacy(util);
@@ -1171,7 +1172,7 @@ function encode(val) {
1171
1172
  *
1172
1173
  * @param {string} url The base of the url (e.g., http://www.google.com)
1173
1174
  * @param {object} [params] The params to be appended
1174
- * @param {?object} options
1175
+ * @param {?(object|Function)} options
1175
1176
  *
1176
1177
  * @returns {string} The formatted url
1177
1178
  */
@@ -1183,6 +1184,12 @@ function buildURL(url, params, options) {
1183
1184
 
1184
1185
  const _encode = options && options.encode || encode;
1185
1186
 
1187
+ if (utils$1.isFunction(options)) {
1188
+ options = {
1189
+ serialize: options
1190
+ };
1191
+ }
1192
+
1186
1193
  const serializeFn = options && options.serialize;
1187
1194
 
1188
1195
  let serializedParams;
@@ -2071,7 +2078,7 @@ function buildFullPath(baseURL, requestedURL) {
2071
2078
  return requestedURL;
2072
2079
  }
2073
2080
 
2074
- const VERSION = "1.7.7";
2081
+ const VERSION = "1.7.8";
2075
2082
 
2076
2083
  function parseProtocol(url) {
2077
2084
  const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
@@ -2283,7 +2290,7 @@ const readBlob$1 = readBlob;
2283
2290
 
2284
2291
  const BOUNDARY_ALPHABET = utils$1.ALPHABET.ALPHA_DIGIT + '-_';
2285
2292
 
2286
- const textEncoder = new util.TextEncoder();
2293
+ const textEncoder = typeof TextEncoder === 'function' ? new TextEncoder() : new util__default["default"].TextEncoder();
2287
2294
 
2288
2295
  const CRLF = '\r\n';
2289
2296
  const CRLF_BYTES = textEncoder.encode(CRLF);
@@ -2621,7 +2628,7 @@ function dispatchBeforeRedirect(options, responseDetails) {
2621
2628
  function setProxy(options, configProxy, location) {
2622
2629
  let proxy = configProxy;
2623
2630
  if (!proxy && proxy !== false) {
2624
- const proxyUrl = proxyFromEnv.getProxyForUrl(location);
2631
+ const proxyUrl = proxyFromEnv__default["default"].getProxyForUrl(location);
2625
2632
  if (proxyUrl) {
2626
2633
  proxy = new URL(proxyUrl);
2627
2634
  }
@@ -2852,7 +2859,7 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
2852
2859
  } catch (e) {
2853
2860
  }
2854
2861
  }
2855
- } else if (utils$1.isBlob(data)) {
2862
+ } else if (utils$1.isBlob(data) || utils$1.isFile(data)) {
2856
2863
  data.size && headers.setContentType(data.type || 'application/octet-stream');
2857
2864
  headers.setContentLength(data.size || 0);
2858
2865
  data = stream__default["default"].Readable.from(readBlob$1(data));
@@ -3105,7 +3112,7 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
3105
3112
  }
3106
3113
 
3107
3114
  const err = new AxiosError(
3108
- 'maxContentLength size of ' + config.maxContentLength + ' exceeded',
3115
+ 'stream has been aborted',
3109
3116
  AxiosError.ERR_BAD_RESPONSE,
3110
3117
  config,
3111
3118
  lastRequest
@@ -3228,68 +3235,18 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
3228
3235
  });
3229
3236
  };
3230
3237
 
3231
- const isURLSameOrigin = platform.hasStandardBrowserEnv ?
3232
-
3233
- // Standard browser envs have full support of the APIs needed to test
3234
- // whether the request URL is of the same origin as current location.
3235
- (function standardBrowserEnv() {
3236
- const msie = platform.navigator && /(msie|trident)/i.test(platform.navigator.userAgent);
3237
- const urlParsingNode = document.createElement('a');
3238
- let originURL;
3239
-
3240
- /**
3241
- * Parse a URL to discover its components
3242
- *
3243
- * @param {String} url The URL to be parsed
3244
- * @returns {Object}
3245
- */
3246
- function resolveURL(url) {
3247
- let href = url;
3248
-
3249
- if (msie) {
3250
- // IE needs attribute set twice to normalize properties
3251
- urlParsingNode.setAttribute('href', href);
3252
- href = urlParsingNode.href;
3253
- }
3254
-
3255
- urlParsingNode.setAttribute('href', href);
3256
-
3257
- // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
3258
- return {
3259
- href: urlParsingNode.href,
3260
- protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
3261
- host: urlParsingNode.host,
3262
- search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
3263
- hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
3264
- hostname: urlParsingNode.hostname,
3265
- port: urlParsingNode.port,
3266
- pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
3267
- urlParsingNode.pathname :
3268
- '/' + urlParsingNode.pathname
3269
- };
3270
- }
3271
-
3272
- originURL = resolveURL(window.location.href);
3273
-
3274
- /**
3275
- * Determine if a URL shares the same origin as the current location
3276
- *
3277
- * @param {String} requestURL The URL to test
3278
- * @returns {boolean} True if URL shares the same origin, otherwise false
3279
- */
3280
- return function isURLSameOrigin(requestURL) {
3281
- const parsed = (utils$1.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
3282
- return (parsed.protocol === originURL.protocol &&
3283
- parsed.host === originURL.host);
3284
- };
3285
- })() :
3238
+ const isURLSameOrigin = platform.hasStandardBrowserEnv ? ((origin, isMSIE) => (url) => {
3239
+ url = new URL(url, platform.origin);
3286
3240
 
3287
- // Non standard browser envs (web workers, react-native) lack needed support.
3288
- (function nonStandardBrowserEnv() {
3289
- return function isURLSameOrigin() {
3290
- return true;
3291
- };
3292
- })();
3241
+ return (
3242
+ origin.protocol === url.protocol &&
3243
+ origin.host === url.host &&
3244
+ (isMSIE || origin.port === url.port)
3245
+ );
3246
+ })(
3247
+ new URL(platform.origin),
3248
+ platform.navigator && /(msie|trident)/i.test(platform.navigator.userAgent)
3249
+ ) : () => true;
3293
3250
 
3294
3251
  const cookies = platform.hasStandardBrowserEnv ?
3295
3252
 
@@ -3346,7 +3303,7 @@ function mergeConfig(config1, config2) {
3346
3303
  config2 = config2 || {};
3347
3304
  const config = {};
3348
3305
 
3349
- function getMergedValue(target, source, caseless) {
3306
+ function getMergedValue(target, source, prop, caseless) {
3350
3307
  if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
3351
3308
  return utils$1.merge.call({caseless}, target, source);
3352
3309
  } else if (utils$1.isPlainObject(source)) {
@@ -3358,11 +3315,11 @@ function mergeConfig(config1, config2) {
3358
3315
  }
3359
3316
 
3360
3317
  // eslint-disable-next-line consistent-return
3361
- function mergeDeepProperties(a, b, caseless) {
3318
+ function mergeDeepProperties(a, b, prop , caseless) {
3362
3319
  if (!utils$1.isUndefined(b)) {
3363
- return getMergedValue(a, b, caseless);
3320
+ return getMergedValue(a, b, prop , caseless);
3364
3321
  } else if (!utils$1.isUndefined(a)) {
3365
- return getMergedValue(undefined, a, caseless);
3322
+ return getMergedValue(undefined, a, prop , caseless);
3366
3323
  }
3367
3324
  }
3368
3325
 
@@ -3420,7 +3377,7 @@ function mergeConfig(config1, config2) {
3420
3377
  socketPath: defaultToConfig2,
3421
3378
  responseEncoding: defaultToConfig2,
3422
3379
  validateStatus: mergeDirectKeys,
3423
- headers: (a, b) => mergeDeepProperties(headersToObject(a), headersToObject(b), true)
3380
+ headers: (a, b , prop) => mergeDeepProperties(headersToObject(a), headersToObject(b),prop, true)
3424
3381
  };
3425
3382
 
3426
3383
  utils$1.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
@@ -4213,6 +4170,14 @@ validators$1.transitional = function transitional(validator, version, message) {
4213
4170
  };
4214
4171
  };
4215
4172
 
4173
+ validators$1.spelling = function spelling(correctSpelling) {
4174
+ return (value, opt) => {
4175
+ // eslint-disable-next-line no-console
4176
+ console.warn(`${opt} is likely a misspelling of ${correctSpelling}`);
4177
+ return true;
4178
+ }
4179
+ };
4180
+
4216
4181
  /**
4217
4182
  * Assert object's properties type
4218
4183
  *
@@ -4282,9 +4247,9 @@ class Axios {
4282
4247
  return await this._request(configOrUrl, config);
4283
4248
  } catch (err) {
4284
4249
  if (err instanceof Error) {
4285
- let dummy;
4250
+ let dummy = {};
4286
4251
 
4287
- Error.captureStackTrace ? Error.captureStackTrace(dummy = {}) : (dummy = new Error());
4252
+ Error.captureStackTrace ? Error.captureStackTrace(dummy) : (dummy = new Error());
4288
4253
 
4289
4254
  // slice off the Error: ... line
4290
4255
  const stack = dummy.stack ? dummy.stack.replace(/^.+\n/, '') : '';
@@ -4339,6 +4304,11 @@ class Axios {
4339
4304
  }
4340
4305
  }
4341
4306
 
4307
+ validator.assertOptions(config, {
4308
+ baseUrl: validators.spelling('baseURL'),
4309
+ withXsrfToken: validators.spelling('withXSRFToken')
4310
+ }, true);
4311
+
4342
4312
  // Set config.method
4343
4313
  config.method = (config.method || this.defaults.method || 'get').toLowerCase();
4344
4314