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.
- package/CHANGELOG.md +49 -0
- package/README.md +20 -8
- package/dist/axios.js +34 -63
- package/dist/axios.js.map +1 -1
- package/dist/axios.min.js +1 -1
- package/dist/axios.min.js.map +1 -1
- package/dist/browser/axios.cjs +40 -71
- package/dist/browser/axios.cjs.map +1 -1
- package/dist/esm/axios.js +40 -71
- package/dist/esm/axios.js.map +1 -1
- package/dist/esm/axios.min.js +1 -1
- package/dist/esm/axios.min.js.map +1 -1
- package/dist/node/axios.cjs +45 -75
- package/dist/node/axios.cjs.map +1 -1
- package/index.d.cts +5 -1
- package/index.d.ts +8 -1
- package/lib/adapters/http.js +4 -4
- package/lib/core/Axios.js +7 -2
- package/lib/core/mergeConfig.js +5 -5
- package/lib/env/data.js +1 -1
- package/lib/helpers/buildURL.js +7 -1
- package/lib/helpers/formDataToStream.js +2 -2
- package/lib/helpers/isURLSameOrigin.js +12 -65
- package/lib/helpers/validator.js +8 -0
- package/package.json +3 -3
package/dist/esm/axios.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
// Axios v1.7.
|
1
|
+
// Axios v1.7.9 Copyright (c) 2024 Matt Zabriskie and contributors
|
2
2
|
function bind(fn, thisArg) {
|
3
3
|
return function wrap() {
|
4
4
|
return fn.apply(thisArg, arguments);
|
@@ -1150,7 +1150,7 @@ function encode(val) {
|
|
1150
1150
|
*
|
1151
1151
|
* @param {string} url The base of the url (e.g., http://www.google.com)
|
1152
1152
|
* @param {object} [params] The params to be appended
|
1153
|
-
* @param {?object} options
|
1153
|
+
* @param {?(object|Function)} options
|
1154
1154
|
*
|
1155
1155
|
* @returns {string} The formatted url
|
1156
1156
|
*/
|
@@ -1162,6 +1162,12 @@ function buildURL(url, params, options) {
|
|
1162
1162
|
|
1163
1163
|
const _encode = options && options.encode || encode;
|
1164
1164
|
|
1165
|
+
if (utils$1.isFunction(options)) {
|
1166
|
+
options = {
|
1167
|
+
serialize: options
|
1168
|
+
};
|
1169
|
+
}
|
1170
|
+
|
1165
1171
|
const serializeFn = options && options.serialize;
|
1166
1172
|
|
1167
1173
|
let serializedParams;
|
@@ -2150,68 +2156,18 @@ const progressEventDecorator = (total, throttled) => {
|
|
2150
2156
|
|
2151
2157
|
const asyncDecorator = (fn) => (...args) => utils$1.asap(() => fn(...args));
|
2152
2158
|
|
2153
|
-
const isURLSameOrigin = platform.hasStandardBrowserEnv ?
|
2154
|
-
|
2155
|
-
// Standard browser envs have full support of the APIs needed to test
|
2156
|
-
// whether the request URL is of the same origin as current location.
|
2157
|
-
(function standardBrowserEnv() {
|
2158
|
-
const msie = platform.navigator && /(msie|trident)/i.test(platform.navigator.userAgent);
|
2159
|
-
const urlParsingNode = document.createElement('a');
|
2160
|
-
let originURL;
|
2161
|
-
|
2162
|
-
/**
|
2163
|
-
* Parse a URL to discover its components
|
2164
|
-
*
|
2165
|
-
* @param {String} url The URL to be parsed
|
2166
|
-
* @returns {Object}
|
2167
|
-
*/
|
2168
|
-
function resolveURL(url) {
|
2169
|
-
let href = url;
|
2170
|
-
|
2171
|
-
if (msie) {
|
2172
|
-
// IE needs attribute set twice to normalize properties
|
2173
|
-
urlParsingNode.setAttribute('href', href);
|
2174
|
-
href = urlParsingNode.href;
|
2175
|
-
}
|
2176
|
-
|
2177
|
-
urlParsingNode.setAttribute('href', href);
|
2178
|
-
|
2179
|
-
// urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
|
2180
|
-
return {
|
2181
|
-
href: urlParsingNode.href,
|
2182
|
-
protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
|
2183
|
-
host: urlParsingNode.host,
|
2184
|
-
search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
|
2185
|
-
hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
|
2186
|
-
hostname: urlParsingNode.hostname,
|
2187
|
-
port: urlParsingNode.port,
|
2188
|
-
pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
|
2189
|
-
urlParsingNode.pathname :
|
2190
|
-
'/' + urlParsingNode.pathname
|
2191
|
-
};
|
2192
|
-
}
|
2193
|
-
|
2194
|
-
originURL = resolveURL(window.location.href);
|
2195
|
-
|
2196
|
-
/**
|
2197
|
-
* Determine if a URL shares the same origin as the current location
|
2198
|
-
*
|
2199
|
-
* @param {String} requestURL The URL to test
|
2200
|
-
* @returns {boolean} True if URL shares the same origin, otherwise false
|
2201
|
-
*/
|
2202
|
-
return function isURLSameOrigin(requestURL) {
|
2203
|
-
const parsed = (utils$1.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
|
2204
|
-
return (parsed.protocol === originURL.protocol &&
|
2205
|
-
parsed.host === originURL.host);
|
2206
|
-
};
|
2207
|
-
})() :
|
2159
|
+
const isURLSameOrigin = platform.hasStandardBrowserEnv ? ((origin, isMSIE) => (url) => {
|
2160
|
+
url = new URL(url, platform.origin);
|
2208
2161
|
|
2209
|
-
|
2210
|
-
|
2211
|
-
|
2212
|
-
|
2213
|
-
|
2214
|
-
|
2162
|
+
return (
|
2163
|
+
origin.protocol === url.protocol &&
|
2164
|
+
origin.host === url.host &&
|
2165
|
+
(isMSIE || origin.port === url.port)
|
2166
|
+
);
|
2167
|
+
})(
|
2168
|
+
new URL(platform.origin),
|
2169
|
+
platform.navigator && /(msie|trident)/i.test(platform.navigator.userAgent)
|
2170
|
+
) : () => true;
|
2215
2171
|
|
2216
2172
|
const cookies = platform.hasStandardBrowserEnv ?
|
2217
2173
|
|
@@ -2313,7 +2269,7 @@ function mergeConfig$1(config1, config2) {
|
|
2313
2269
|
config2 = config2 || {};
|
2314
2270
|
const config = {};
|
2315
2271
|
|
2316
|
-
function getMergedValue(target, source, caseless) {
|
2272
|
+
function getMergedValue(target, source, prop, caseless) {
|
2317
2273
|
if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
|
2318
2274
|
return utils$1.merge.call({caseless}, target, source);
|
2319
2275
|
} else if (utils$1.isPlainObject(source)) {
|
@@ -2325,11 +2281,11 @@ function mergeConfig$1(config1, config2) {
|
|
2325
2281
|
}
|
2326
2282
|
|
2327
2283
|
// eslint-disable-next-line consistent-return
|
2328
|
-
function mergeDeepProperties(a, b, caseless) {
|
2284
|
+
function mergeDeepProperties(a, b, prop , caseless) {
|
2329
2285
|
if (!utils$1.isUndefined(b)) {
|
2330
|
-
return getMergedValue(a, b, caseless);
|
2286
|
+
return getMergedValue(a, b, prop , caseless);
|
2331
2287
|
} else if (!utils$1.isUndefined(a)) {
|
2332
|
-
return getMergedValue(undefined, a, caseless);
|
2288
|
+
return getMergedValue(undefined, a, prop , caseless);
|
2333
2289
|
}
|
2334
2290
|
}
|
2335
2291
|
|
@@ -2387,7 +2343,7 @@ function mergeConfig$1(config1, config2) {
|
|
2387
2343
|
socketPath: defaultToConfig2,
|
2388
2344
|
responseEncoding: defaultToConfig2,
|
2389
2345
|
validateStatus: mergeDirectKeys,
|
2390
|
-
headers: (a, b) => mergeDeepProperties(headersToObject(a), headersToObject(b), true)
|
2346
|
+
headers: (a, b , prop) => mergeDeepProperties(headersToObject(a), headersToObject(b),prop, true)
|
2391
2347
|
};
|
2392
2348
|
|
2393
2349
|
utils$1.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
|
@@ -3131,7 +3087,7 @@ function dispatchRequest(config) {
|
|
3131
3087
|
});
|
3132
3088
|
}
|
3133
3089
|
|
3134
|
-
const VERSION$1 = "1.7.
|
3090
|
+
const VERSION$1 = "1.7.9";
|
3135
3091
|
|
3136
3092
|
const validators$1 = {};
|
3137
3093
|
|
@@ -3182,6 +3138,14 @@ validators$1.transitional = function transitional(validator, version, message) {
|
|
3182
3138
|
};
|
3183
3139
|
};
|
3184
3140
|
|
3141
|
+
validators$1.spelling = function spelling(correctSpelling) {
|
3142
|
+
return (value, opt) => {
|
3143
|
+
// eslint-disable-next-line no-console
|
3144
|
+
console.warn(`${opt} is likely a misspelling of ${correctSpelling}`);
|
3145
|
+
return true;
|
3146
|
+
}
|
3147
|
+
};
|
3148
|
+
|
3185
3149
|
/**
|
3186
3150
|
* Assert object's properties type
|
3187
3151
|
*
|
@@ -3251,9 +3215,9 @@ class Axios$1 {
|
|
3251
3215
|
return await this._request(configOrUrl, config);
|
3252
3216
|
} catch (err) {
|
3253
3217
|
if (err instanceof Error) {
|
3254
|
-
let dummy;
|
3218
|
+
let dummy = {};
|
3255
3219
|
|
3256
|
-
Error.captureStackTrace ? Error.captureStackTrace(dummy
|
3220
|
+
Error.captureStackTrace ? Error.captureStackTrace(dummy) : (dummy = new Error());
|
3257
3221
|
|
3258
3222
|
// slice off the Error: ... line
|
3259
3223
|
const stack = dummy.stack ? dummy.stack.replace(/^.+\n/, '') : '';
|
@@ -3308,6 +3272,11 @@ class Axios$1 {
|
|
3308
3272
|
}
|
3309
3273
|
}
|
3310
3274
|
|
3275
|
+
validator.assertOptions(config, {
|
3276
|
+
baseUrl: validators.spelling('baseURL'),
|
3277
|
+
withXsrfToken: validators.spelling('withXSRFToken')
|
3278
|
+
}, true);
|
3279
|
+
|
3311
3280
|
// Set config.method
|
3312
3281
|
config.method = (config.method || this.defaults.method || 'get').toLowerCase();
|
3313
3282
|
|