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/index.d.cts
CHANGED
package/index.d.ts
CHANGED
@@ -119,10 +119,7 @@ export interface AxiosBasicCredentials {
|
|
119
119
|
export interface AxiosProxyConfig {
|
120
120
|
host: string;
|
121
121
|
port: number;
|
122
|
-
auth?:
|
123
|
-
username: string;
|
124
|
-
password: string;
|
125
|
-
};
|
122
|
+
auth?: AxiosBasicCredentials;
|
126
123
|
protocol?: string;
|
127
124
|
}
|
128
125
|
|
package/lib/adapters/adapters.js
CHANGED
@@ -9,7 +9,7 @@ const knownAdapters = {
|
|
9
9
|
}
|
10
10
|
|
11
11
|
utils.forEach(knownAdapters, (fn, value) => {
|
12
|
-
if(fn) {
|
12
|
+
if (fn) {
|
13
13
|
try {
|
14
14
|
Object.defineProperty(fn, 'name', {value});
|
15
15
|
} catch (e) {
|
@@ -19,6 +19,10 @@ utils.forEach(knownAdapters, (fn, value) => {
|
|
19
19
|
}
|
20
20
|
});
|
21
21
|
|
22
|
+
const renderReason = (reason) => `- ${reason}`;
|
23
|
+
|
24
|
+
const isResolvedHandle = (adapter) => utils.isFunction(adapter) || adapter === null || adapter === false;
|
25
|
+
|
22
26
|
export default {
|
23
27
|
getAdapter: (adapters) => {
|
24
28
|
adapters = utils.isArray(adapters) ? adapters : [adapters];
|
@@ -27,30 +31,44 @@ export default {
|
|
27
31
|
let nameOrAdapter;
|
28
32
|
let adapter;
|
29
33
|
|
34
|
+
const rejectedReasons = {};
|
35
|
+
|
30
36
|
for (let i = 0; i < length; i++) {
|
31
37
|
nameOrAdapter = adapters[i];
|
32
|
-
|
38
|
+
let id;
|
39
|
+
|
40
|
+
adapter = nameOrAdapter;
|
41
|
+
|
42
|
+
if (!isResolvedHandle(nameOrAdapter)) {
|
43
|
+
adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];
|
44
|
+
|
45
|
+
if (adapter === undefined) {
|
46
|
+
throw new AxiosError(`Unknown adapter '${id}'`);
|
47
|
+
}
|
48
|
+
}
|
49
|
+
|
50
|
+
if (adapter) {
|
33
51
|
break;
|
34
52
|
}
|
53
|
+
|
54
|
+
rejectedReasons[id || '#' + i] = adapter;
|
35
55
|
}
|
36
56
|
|
37
57
|
if (!adapter) {
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
'
|
58
|
+
|
59
|
+
const reasons = Object.entries(rejectedReasons)
|
60
|
+
.map(([id, state]) => `adapter ${id} ` +
|
61
|
+
(state === false ? 'is not supported by the environment' : 'is not available in the build')
|
42
62
|
);
|
43
|
-
}
|
44
63
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
`Unknown adapter '${nameOrAdapter}'`
|
49
|
-
);
|
50
|
-
}
|
64
|
+
let s = length ?
|
65
|
+
(reasons.length > 1 ? 'since :\n' + reasons.map(renderReason).join('\n') : ' ' + renderReason(reasons[0])) :
|
66
|
+
'as no adapter specified';
|
51
67
|
|
52
|
-
|
53
|
-
|
68
|
+
throw new AxiosError(
|
69
|
+
`There is no suitable adapter to dispatch the request ` + s,
|
70
|
+
'ERR_NOT_SUPPORT'
|
71
|
+
);
|
54
72
|
}
|
55
73
|
|
56
74
|
return adapter;
|
package/lib/adapters/http.js
CHANGED
@@ -471,7 +471,7 @@ export default isHttpAdapterSupported && function httpAdapter(config) {
|
|
471
471
|
delete res.headers['content-encoding'];
|
472
472
|
}
|
473
473
|
|
474
|
-
switch (res.headers['content-encoding']) {
|
474
|
+
switch ((res.headers['content-encoding'] || '').toLowerCase()) {
|
475
475
|
/*eslint default-case:0*/
|
476
476
|
case 'gzip':
|
477
477
|
case 'x-gzip':
|
@@ -604,7 +604,7 @@ export default isHttpAdapterSupported && function httpAdapter(config) {
|
|
604
604
|
// This is forcing a int timeout to avoid problems if the `req` interface doesn't handle other types.
|
605
605
|
const timeout = parseInt(config.timeout, 10);
|
606
606
|
|
607
|
-
if (isNaN(timeout)) {
|
607
|
+
if (Number.isNaN(timeout)) {
|
608
608
|
reject(new AxiosError(
|
609
609
|
'error trying to parse `config.timeout` to int',
|
610
610
|
AxiosError.ERR_BAD_OPTION_VALUE,
|
package/lib/adapters/xhr.js
CHANGED
@@ -61,11 +61,16 @@ export default isXHRAdapterSupported && function (config) {
|
|
61
61
|
}
|
62
62
|
}
|
63
63
|
|
64
|
+
let contentType;
|
65
|
+
|
64
66
|
if (utils.isFormData(requestData)) {
|
65
67
|
if (platform.isStandardBrowserEnv || platform.isStandardBrowserWebWorkerEnv) {
|
66
68
|
requestHeaders.setContentType(false); // Let the browser set it
|
67
|
-
} else {
|
68
|
-
requestHeaders.setContentType('multipart/form-data
|
69
|
+
} else if(!requestHeaders.getContentType(/^\s*multipart\/form-data/)){
|
70
|
+
requestHeaders.setContentType('multipart/form-data'); // mobile/desktop app frameworks
|
71
|
+
} else if(utils.isString(contentType = requestHeaders.getContentType())){
|
72
|
+
// fix semicolon duplication issue for ReactNative FormData implementation
|
73
|
+
requestHeaders.setContentType(contentType.replace(/^\s*(multipart\/form-data);+/, '$1'))
|
69
74
|
}
|
70
75
|
}
|
71
76
|
|
package/lib/defaults/index.js
CHANGED
@@ -37,7 +37,7 @@ const defaults = {
|
|
37
37
|
|
38
38
|
transitional: transitionalDefaults,
|
39
39
|
|
40
|
-
adapter:
|
40
|
+
adapter: ['xhr', 'http'],
|
41
41
|
|
42
42
|
transformRequest: [function transformRequest(data, headers) {
|
43
43
|
const contentType = headers.getContentType() || '';
|
package/lib/env/data.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export const VERSION = "1.5.
|
1
|
+
export const VERSION = "1.5.1";
|