axios 1.5.0 → 1.5.1
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 +19 -0
- package/README.md +12 -6
- package/dist/axios.js +34 -14
- 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 +43 -20
- package/dist/browser/axios.cjs.map +1 -1
- package/dist/esm/axios.js +43 -20
- 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 -22
- package/dist/node/axios.cjs.map +1 -1
- package/index.d.cts +1 -4
- package/index.d.ts +1 -4
- package/lib/adapters/adapters.js +33 -15
- package/lib/adapters/http.js +2 -2
- package/lib/adapters/xhr.js +7 -2
- package/lib/defaults/index.js +1 -1
- package/lib/env/data.js +1 -1
- package/package.json +1 -1
package/dist/node/axios.cjs
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
// Axios v1.5.
|
1
|
+
// Axios v1.5.1 Copyright (c) 2023 Matt Zabriskie and contributors
|
2
2
|
'use strict';
|
3
3
|
|
4
4
|
const FormData$1 = require('form-data');
|
@@ -1383,7 +1383,7 @@ const defaults = {
|
|
1383
1383
|
|
1384
1384
|
transitional: transitionalDefaults,
|
1385
1385
|
|
1386
|
-
adapter: 'http'
|
1386
|
+
adapter: ['xhr', 'http'],
|
1387
1387
|
|
1388
1388
|
transformRequest: [function transformRequest(data, headers) {
|
1389
1389
|
const contentType = headers.getContentType() || '';
|
@@ -1965,7 +1965,7 @@ function buildFullPath(baseURL, requestedURL) {
|
|
1965
1965
|
return requestedURL;
|
1966
1966
|
}
|
1967
1967
|
|
1968
|
-
const VERSION = "1.5.
|
1968
|
+
const VERSION = "1.5.1";
|
1969
1969
|
|
1970
1970
|
function parseProtocol(url) {
|
1971
1971
|
const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
|
@@ -2894,7 +2894,7 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
|
|
2894
2894
|
delete res.headers['content-encoding'];
|
2895
2895
|
}
|
2896
2896
|
|
2897
|
-
switch (res.headers['content-encoding']) {
|
2897
|
+
switch ((res.headers['content-encoding'] || '').toLowerCase()) {
|
2898
2898
|
/*eslint default-case:0*/
|
2899
2899
|
case 'gzip':
|
2900
2900
|
case 'x-gzip':
|
@@ -3027,7 +3027,7 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
|
|
3027
3027
|
// This is forcing a int timeout to avoid problems if the `req` interface doesn't handle other types.
|
3028
3028
|
const timeout = parseInt(config.timeout, 10);
|
3029
3029
|
|
3030
|
-
if (isNaN(timeout)) {
|
3030
|
+
if (Number.isNaN(timeout)) {
|
3031
3031
|
reject(new AxiosError(
|
3032
3032
|
'error trying to parse `config.timeout` to int',
|
3033
3033
|
AxiosError.ERR_BAD_OPTION_VALUE,
|
@@ -3246,11 +3246,16 @@ const xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
3246
3246
|
}
|
3247
3247
|
}
|
3248
3248
|
|
3249
|
+
let contentType;
|
3250
|
+
|
3249
3251
|
if (utils.isFormData(requestData)) {
|
3250
3252
|
if (platform.isStandardBrowserEnv || platform.isStandardBrowserWebWorkerEnv) {
|
3251
3253
|
requestHeaders.setContentType(false); // Let the browser set it
|
3252
|
-
} else {
|
3253
|
-
requestHeaders.setContentType('multipart/form-data
|
3254
|
+
} else if(!requestHeaders.getContentType(/^\s*multipart\/form-data/)){
|
3255
|
+
requestHeaders.setContentType('multipart/form-data'); // mobile/desktop app frameworks
|
3256
|
+
} else if(utils.isString(contentType = requestHeaders.getContentType())){
|
3257
|
+
// fix semicolon duplication issue for ReactNative FormData implementation
|
3258
|
+
requestHeaders.setContentType(contentType.replace(/^\s*(multipart\/form-data);+/, '$1'));
|
3254
3259
|
}
|
3255
3260
|
}
|
3256
3261
|
|
@@ -3443,7 +3448,7 @@ const knownAdapters = {
|
|
3443
3448
|
};
|
3444
3449
|
|
3445
3450
|
utils.forEach(knownAdapters, (fn, value) => {
|
3446
|
-
if(fn) {
|
3451
|
+
if (fn) {
|
3447
3452
|
try {
|
3448
3453
|
Object.defineProperty(fn, 'name', {value});
|
3449
3454
|
} catch (e) {
|
@@ -3453,6 +3458,10 @@ utils.forEach(knownAdapters, (fn, value) => {
|
|
3453
3458
|
}
|
3454
3459
|
});
|
3455
3460
|
|
3461
|
+
const renderReason = (reason) => `- ${reason}`;
|
3462
|
+
|
3463
|
+
const isResolvedHandle = (adapter) => utils.isFunction(adapter) || adapter === null || adapter === false;
|
3464
|
+
|
3456
3465
|
const adapters = {
|
3457
3466
|
getAdapter: (adapters) => {
|
3458
3467
|
adapters = utils.isArray(adapters) ? adapters : [adapters];
|
@@ -3461,30 +3470,44 @@ const adapters = {
|
|
3461
3470
|
let nameOrAdapter;
|
3462
3471
|
let adapter;
|
3463
3472
|
|
3473
|
+
const rejectedReasons = {};
|
3474
|
+
|
3464
3475
|
for (let i = 0; i < length; i++) {
|
3465
3476
|
nameOrAdapter = adapters[i];
|
3466
|
-
|
3477
|
+
let id;
|
3478
|
+
|
3479
|
+
adapter = nameOrAdapter;
|
3480
|
+
|
3481
|
+
if (!isResolvedHandle(nameOrAdapter)) {
|
3482
|
+
adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];
|
3483
|
+
|
3484
|
+
if (adapter === undefined) {
|
3485
|
+
throw new AxiosError(`Unknown adapter '${id}'`);
|
3486
|
+
}
|
3487
|
+
}
|
3488
|
+
|
3489
|
+
if (adapter) {
|
3467
3490
|
break;
|
3468
3491
|
}
|
3492
|
+
|
3493
|
+
rejectedReasons[id || '#' + i] = adapter;
|
3469
3494
|
}
|
3470
3495
|
|
3471
3496
|
if (!adapter) {
|
3472
|
-
|
3473
|
-
|
3474
|
-
|
3475
|
-
'
|
3497
|
+
|
3498
|
+
const reasons = Object.entries(rejectedReasons)
|
3499
|
+
.map(([id, state]) => `adapter ${id} ` +
|
3500
|
+
(state === false ? 'is not supported by the environment' : 'is not available in the build')
|
3476
3501
|
);
|
3477
|
-
}
|
3478
3502
|
|
3479
|
-
|
3480
|
-
|
3481
|
-
|
3482
|
-
`Unknown adapter '${nameOrAdapter}'`
|
3483
|
-
);
|
3484
|
-
}
|
3503
|
+
let s = length ?
|
3504
|
+
(reasons.length > 1 ? 'since :\n' + reasons.map(renderReason).join('\n') : ' ' + renderReason(reasons[0])) :
|
3505
|
+
'as no adapter specified';
|
3485
3506
|
|
3486
|
-
|
3487
|
-
|
3507
|
+
throw new AxiosError(
|
3508
|
+
`There is no suitable adapter to dispatch the request ` + s,
|
3509
|
+
'ERR_NOT_SUPPORT'
|
3510
|
+
);
|
3488
3511
|
}
|
3489
3512
|
|
3490
3513
|
return adapter;
|