axios 1.7.7 → 1.7.9

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.9 Copyright (c) 2024 Matt Zabriskie and contributors
2
2
  'use strict';
3
3
 
4
4
  function bind(fn, thisArg) {
@@ -1152,7 +1152,7 @@ function encode(val) {
1152
1152
  *
1153
1153
  * @param {string} url The base of the url (e.g., http://www.google.com)
1154
1154
  * @param {object} [params] The params to be appended
1155
- * @param {?object} options
1155
+ * @param {?(object|Function)} options
1156
1156
  *
1157
1157
  * @returns {string} The formatted url
1158
1158
  */
@@ -1164,6 +1164,12 @@ function buildURL(url, params, options) {
1164
1164
 
1165
1165
  const _encode = options && options.encode || encode;
1166
1166
 
1167
+ if (utils$1.isFunction(options)) {
1168
+ options = {
1169
+ serialize: options
1170
+ };
1171
+ }
1172
+
1167
1173
  const serializeFn = options && options.serialize;
1168
1174
 
1169
1175
  let serializedParams;
@@ -2152,68 +2158,18 @@ const progressEventDecorator = (total, throttled) => {
2152
2158
 
2153
2159
  const asyncDecorator = (fn) => (...args) => utils$1.asap(() => fn(...args));
2154
2160
 
2155
- var isURLSameOrigin = platform.hasStandardBrowserEnv ?
2156
-
2157
- // Standard browser envs have full support of the APIs needed to test
2158
- // whether the request URL is of the same origin as current location.
2159
- (function standardBrowserEnv() {
2160
- const msie = platform.navigator && /(msie|trident)/i.test(platform.navigator.userAgent);
2161
- const urlParsingNode = document.createElement('a');
2162
- let originURL;
2163
-
2164
- /**
2165
- * Parse a URL to discover its components
2166
- *
2167
- * @param {String} url The URL to be parsed
2168
- * @returns {Object}
2169
- */
2170
- function resolveURL(url) {
2171
- let href = url;
2172
-
2173
- if (msie) {
2174
- // IE needs attribute set twice to normalize properties
2175
- urlParsingNode.setAttribute('href', href);
2176
- href = urlParsingNode.href;
2177
- }
2178
-
2179
- urlParsingNode.setAttribute('href', href);
2180
-
2181
- // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
2182
- return {
2183
- href: urlParsingNode.href,
2184
- protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
2185
- host: urlParsingNode.host,
2186
- search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
2187
- hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
2188
- hostname: urlParsingNode.hostname,
2189
- port: urlParsingNode.port,
2190
- pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
2191
- urlParsingNode.pathname :
2192
- '/' + urlParsingNode.pathname
2193
- };
2194
- }
2195
-
2196
- originURL = resolveURL(window.location.href);
2197
-
2198
- /**
2199
- * Determine if a URL shares the same origin as the current location
2200
- *
2201
- * @param {String} requestURL The URL to test
2202
- * @returns {boolean} True if URL shares the same origin, otherwise false
2203
- */
2204
- return function isURLSameOrigin(requestURL) {
2205
- const parsed = (utils$1.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
2206
- return (parsed.protocol === originURL.protocol &&
2207
- parsed.host === originURL.host);
2208
- };
2209
- })() :
2161
+ var isURLSameOrigin = platform.hasStandardBrowserEnv ? ((origin, isMSIE) => (url) => {
2162
+ url = new URL(url, platform.origin);
2210
2163
 
2211
- // Non standard browser envs (web workers, react-native) lack needed support.
2212
- (function nonStandardBrowserEnv() {
2213
- return function isURLSameOrigin() {
2214
- return true;
2215
- };
2216
- })();
2164
+ return (
2165
+ origin.protocol === url.protocol &&
2166
+ origin.host === url.host &&
2167
+ (isMSIE || origin.port === url.port)
2168
+ );
2169
+ })(
2170
+ new URL(platform.origin),
2171
+ platform.navigator && /(msie|trident)/i.test(platform.navigator.userAgent)
2172
+ ) : () => true;
2217
2173
 
2218
2174
  var cookies = platform.hasStandardBrowserEnv ?
2219
2175
 
@@ -2315,7 +2271,7 @@ function mergeConfig(config1, config2) {
2315
2271
  config2 = config2 || {};
2316
2272
  const config = {};
2317
2273
 
2318
- function getMergedValue(target, source, caseless) {
2274
+ function getMergedValue(target, source, prop, caseless) {
2319
2275
  if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
2320
2276
  return utils$1.merge.call({caseless}, target, source);
2321
2277
  } else if (utils$1.isPlainObject(source)) {
@@ -2327,11 +2283,11 @@ function mergeConfig(config1, config2) {
2327
2283
  }
2328
2284
 
2329
2285
  // eslint-disable-next-line consistent-return
2330
- function mergeDeepProperties(a, b, caseless) {
2286
+ function mergeDeepProperties(a, b, prop , caseless) {
2331
2287
  if (!utils$1.isUndefined(b)) {
2332
- return getMergedValue(a, b, caseless);
2288
+ return getMergedValue(a, b, prop , caseless);
2333
2289
  } else if (!utils$1.isUndefined(a)) {
2334
- return getMergedValue(undefined, a, caseless);
2290
+ return getMergedValue(undefined, a, prop , caseless);
2335
2291
  }
2336
2292
  }
2337
2293
 
@@ -2389,7 +2345,7 @@ function mergeConfig(config1, config2) {
2389
2345
  socketPath: defaultToConfig2,
2390
2346
  responseEncoding: defaultToConfig2,
2391
2347
  validateStatus: mergeDirectKeys,
2392
- headers: (a, b) => mergeDeepProperties(headersToObject(a), headersToObject(b), true)
2348
+ headers: (a, b , prop) => mergeDeepProperties(headersToObject(a), headersToObject(b),prop, true)
2393
2349
  };
2394
2350
 
2395
2351
  utils$1.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
@@ -3133,7 +3089,7 @@ function dispatchRequest(config) {
3133
3089
  });
3134
3090
  }
3135
3091
 
3136
- const VERSION = "1.7.7";
3092
+ const VERSION = "1.7.9";
3137
3093
 
3138
3094
  const validators$1 = {};
3139
3095
 
@@ -3184,6 +3140,14 @@ validators$1.transitional = function transitional(validator, version, message) {
3184
3140
  };
3185
3141
  };
3186
3142
 
3143
+ validators$1.spelling = function spelling(correctSpelling) {
3144
+ return (value, opt) => {
3145
+ // eslint-disable-next-line no-console
3146
+ console.warn(`${opt} is likely a misspelling of ${correctSpelling}`);
3147
+ return true;
3148
+ }
3149
+ };
3150
+
3187
3151
  /**
3188
3152
  * Assert object's properties type
3189
3153
  *
@@ -3253,9 +3217,9 @@ class Axios {
3253
3217
  return await this._request(configOrUrl, config);
3254
3218
  } catch (err) {
3255
3219
  if (err instanceof Error) {
3256
- let dummy;
3220
+ let dummy = {};
3257
3221
 
3258
- Error.captureStackTrace ? Error.captureStackTrace(dummy = {}) : (dummy = new Error());
3222
+ Error.captureStackTrace ? Error.captureStackTrace(dummy) : (dummy = new Error());
3259
3223
 
3260
3224
  // slice off the Error: ... line
3261
3225
  const stack = dummy.stack ? dummy.stack.replace(/^.+\n/, '') : '';
@@ -3310,6 +3274,11 @@ class Axios {
3310
3274
  }
3311
3275
  }
3312
3276
 
3277
+ validator.assertOptions(config, {
3278
+ baseUrl: validators.spelling('baseURL'),
3279
+ withXsrfToken: validators.spelling('withXSRFToken')
3280
+ }, true);
3281
+
3313
3282
  // Set config.method
3314
3283
  config.method = (config.method || this.defaults.method || 'get').toLowerCase();
3315
3284