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/index.d.cts
CHANGED
@@ -493,8 +493,12 @@ declare namespace axios {
|
|
493
493
|
runWhen?: (config: InternalAxiosRequestConfig) => boolean;
|
494
494
|
}
|
495
495
|
|
496
|
+
type AxiosRequestInterceptorUse<T> = (onFulfilled?: ((value: T) => T | Promise<T>) | null, onRejected?: ((error: any) => any) | null, options?: AxiosInterceptorOptions) => number;
|
497
|
+
|
498
|
+
type AxiosResponseInterceptorUse<T> = (onFulfilled?: ((value: T) => T | Promise<T>) | null, onRejected?: ((error: any) => any) | null) => number;
|
499
|
+
|
496
500
|
interface AxiosInterceptorManager<V> {
|
497
|
-
use
|
501
|
+
use: V extends AxiosResponse ? AxiosResponseInterceptorUse<V> : AxiosRequestInterceptorUse<V>;
|
498
502
|
eject(id: number): void;
|
499
503
|
clear(): void;
|
500
504
|
}
|
package/index.d.ts
CHANGED
@@ -476,8 +476,12 @@ export interface AxiosInterceptorOptions {
|
|
476
476
|
runWhen?: (config: InternalAxiosRequestConfig) => boolean;
|
477
477
|
}
|
478
478
|
|
479
|
+
type AxiosRequestInterceptorUse<T> = (onFulfilled?: ((value: T) => T | Promise<T>) | null, onRejected?: ((error: any) => any) | null, options?: AxiosInterceptorOptions) => number;
|
480
|
+
|
481
|
+
type AxiosResponseInterceptorUse<T> = (onFulfilled?: ((value: T) => T | Promise<T>) | null, onRejected?: ((error: any) => any) | null) => number;
|
482
|
+
|
479
483
|
export interface AxiosInterceptorManager<V> {
|
480
|
-
use
|
484
|
+
use: V extends AxiosResponse ? AxiosResponseInterceptorUse<V> : AxiosRequestInterceptorUse<V>;
|
481
485
|
eject(id: number): void;
|
482
486
|
clear(): void;
|
483
487
|
}
|
@@ -538,6 +542,8 @@ export function isCancel(value: any): value is Cancel;
|
|
538
542
|
|
539
543
|
export function all<T>(values: Array<T | Promise<T>>): Promise<T[]>;
|
540
544
|
|
545
|
+
export function mergeConfig<D = any>(config1: AxiosRequestConfig<D>, config2: AxiosRequestConfig<D>): AxiosRequestConfig<D>;
|
546
|
+
|
541
547
|
export interface AxiosStatic extends AxiosInstance {
|
542
548
|
create(config?: CreateAxiosDefaults): AxiosInstance;
|
543
549
|
Cancel: CancelStatic;
|
@@ -555,6 +561,7 @@ export interface AxiosStatic extends AxiosInstance {
|
|
555
561
|
getAdapter: typeof getAdapter;
|
556
562
|
CanceledError: typeof CanceledError;
|
557
563
|
AxiosHeaders: typeof AxiosHeaders;
|
564
|
+
mergeConfig: typeof mergeConfig;
|
558
565
|
}
|
559
566
|
|
560
567
|
declare const axios: AxiosStatic;
|
package/lib/adapters/http.js
CHANGED
@@ -4,7 +4,7 @@ import utils from './../utils.js';
|
|
4
4
|
import settle from './../core/settle.js';
|
5
5
|
import buildFullPath from '../core/buildFullPath.js';
|
6
6
|
import buildURL from './../helpers/buildURL.js';
|
7
|
-
import
|
7
|
+
import proxyFromEnv from 'proxy-from-env';
|
8
8
|
import http from 'http';
|
9
9
|
import https from 'https';
|
10
10
|
import util from 'util';
|
@@ -83,7 +83,7 @@ function dispatchBeforeRedirect(options, responseDetails) {
|
|
83
83
|
function setProxy(options, configProxy, location) {
|
84
84
|
let proxy = configProxy;
|
85
85
|
if (!proxy && proxy !== false) {
|
86
|
-
const proxyUrl = getProxyForUrl(location);
|
86
|
+
const proxyUrl = proxyFromEnv.getProxyForUrl(location);
|
87
87
|
if (proxyUrl) {
|
88
88
|
proxy = new URL(proxyUrl);
|
89
89
|
}
|
@@ -314,7 +314,7 @@ export default isHttpAdapterSupported && function httpAdapter(config) {
|
|
314
314
|
} catch (e) {
|
315
315
|
}
|
316
316
|
}
|
317
|
-
} else if (utils.isBlob(data)) {
|
317
|
+
} else if (utils.isBlob(data) || utils.isFile(data)) {
|
318
318
|
data.size && headers.setContentType(data.type || 'application/octet-stream');
|
319
319
|
headers.setContentLength(data.size || 0);
|
320
320
|
data = stream.Readable.from(readBlob(data));
|
@@ -569,7 +569,7 @@ export default isHttpAdapterSupported && function httpAdapter(config) {
|
|
569
569
|
}
|
570
570
|
|
571
571
|
const err = new AxiosError(
|
572
|
-
'
|
572
|
+
'stream has been aborted',
|
573
573
|
AxiosError.ERR_BAD_RESPONSE,
|
574
574
|
config,
|
575
575
|
lastRequest
|
package/lib/core/Axios.js
CHANGED
@@ -40,9 +40,9 @@ class Axios {
|
|
40
40
|
return await this._request(configOrUrl, config);
|
41
41
|
} catch (err) {
|
42
42
|
if (err instanceof Error) {
|
43
|
-
let dummy;
|
43
|
+
let dummy = {};
|
44
44
|
|
45
|
-
Error.captureStackTrace ? Error.captureStackTrace(dummy
|
45
|
+
Error.captureStackTrace ? Error.captureStackTrace(dummy) : (dummy = new Error());
|
46
46
|
|
47
47
|
// slice off the Error: ... line
|
48
48
|
const stack = dummy.stack ? dummy.stack.replace(/^.+\n/, '') : '';
|
@@ -97,6 +97,11 @@ class Axios {
|
|
97
97
|
}
|
98
98
|
}
|
99
99
|
|
100
|
+
validator.assertOptions(config, {
|
101
|
+
baseUrl: validators.spelling('baseURL'),
|
102
|
+
withXsrfToken: validators.spelling('withXSRFToken')
|
103
|
+
}, true);
|
104
|
+
|
100
105
|
// Set config.method
|
101
106
|
config.method = (config.method || this.defaults.method || 'get').toLowerCase();
|
102
107
|
|
package/lib/core/mergeConfig.js
CHANGED
@@ -19,7 +19,7 @@ export default function mergeConfig(config1, config2) {
|
|
19
19
|
config2 = config2 || {};
|
20
20
|
const config = {};
|
21
21
|
|
22
|
-
function getMergedValue(target, source, caseless) {
|
22
|
+
function getMergedValue(target, source, prop, caseless) {
|
23
23
|
if (utils.isPlainObject(target) && utils.isPlainObject(source)) {
|
24
24
|
return utils.merge.call({caseless}, target, source);
|
25
25
|
} else if (utils.isPlainObject(source)) {
|
@@ -31,11 +31,11 @@ export default function mergeConfig(config1, config2) {
|
|
31
31
|
}
|
32
32
|
|
33
33
|
// eslint-disable-next-line consistent-return
|
34
|
-
function mergeDeepProperties(a, b, caseless) {
|
34
|
+
function mergeDeepProperties(a, b, prop , caseless) {
|
35
35
|
if (!utils.isUndefined(b)) {
|
36
|
-
return getMergedValue(a, b, caseless);
|
36
|
+
return getMergedValue(a, b, prop , caseless);
|
37
37
|
} else if (!utils.isUndefined(a)) {
|
38
|
-
return getMergedValue(undefined, a, caseless);
|
38
|
+
return getMergedValue(undefined, a, prop , caseless);
|
39
39
|
}
|
40
40
|
}
|
41
41
|
|
@@ -93,7 +93,7 @@ export default function mergeConfig(config1, config2) {
|
|
93
93
|
socketPath: defaultToConfig2,
|
94
94
|
responseEncoding: defaultToConfig2,
|
95
95
|
validateStatus: mergeDirectKeys,
|
96
|
-
headers: (a, b) => mergeDeepProperties(headersToObject(a), headersToObject(b), true)
|
96
|
+
headers: (a, b , prop) => mergeDeepProperties(headersToObject(a), headersToObject(b),prop, true)
|
97
97
|
};
|
98
98
|
|
99
99
|
utils.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
|
package/lib/env/data.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export const VERSION = "1.7.
|
1
|
+
export const VERSION = "1.7.9";
|
package/lib/helpers/buildURL.js
CHANGED
@@ -26,7 +26,7 @@ function encode(val) {
|
|
26
26
|
*
|
27
27
|
* @param {string} url The base of the url (e.g., http://www.google.com)
|
28
28
|
* @param {object} [params] The params to be appended
|
29
|
-
* @param {?object} options
|
29
|
+
* @param {?(object|Function)} options
|
30
30
|
*
|
31
31
|
* @returns {string} The formatted url
|
32
32
|
*/
|
@@ -38,6 +38,12 @@ export default function buildURL(url, params, options) {
|
|
38
38
|
|
39
39
|
const _encode = options && options.encode || encode;
|
40
40
|
|
41
|
+
if (utils.isFunction(options)) {
|
42
|
+
options = {
|
43
|
+
serialize: options
|
44
|
+
};
|
45
|
+
}
|
46
|
+
|
41
47
|
const serializeFn = options && options.serialize;
|
42
48
|
|
43
49
|
let serializedParams;
|
@@ -1,11 +1,11 @@
|
|
1
|
-
import
|
1
|
+
import util from 'util';
|
2
2
|
import {Readable} from 'stream';
|
3
3
|
import utils from "../utils.js";
|
4
4
|
import readBlob from "./readBlob.js";
|
5
5
|
|
6
6
|
const BOUNDARY_ALPHABET = utils.ALPHABET.ALPHA_DIGIT + '-_';
|
7
7
|
|
8
|
-
const textEncoder = new TextEncoder();
|
8
|
+
const textEncoder = typeof TextEncoder === 'function' ? new TextEncoder() : new util.TextEncoder();
|
9
9
|
|
10
10
|
const CRLF = '\r\n';
|
11
11
|
const CRLF_BYTES = textEncoder.encode(CRLF);
|
@@ -1,67 +1,14 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
import utils from './../utils.js';
|
4
1
|
import platform from '../platform/index.js';
|
5
2
|
|
6
|
-
export default platform.hasStandardBrowserEnv ?
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
* @param {String} url The URL to be parsed
|
19
|
-
* @returns {Object}
|
20
|
-
*/
|
21
|
-
function resolveURL(url) {
|
22
|
-
let href = url;
|
23
|
-
|
24
|
-
if (msie) {
|
25
|
-
// IE needs attribute set twice to normalize properties
|
26
|
-
urlParsingNode.setAttribute('href', href);
|
27
|
-
href = urlParsingNode.href;
|
28
|
-
}
|
29
|
-
|
30
|
-
urlParsingNode.setAttribute('href', href);
|
31
|
-
|
32
|
-
// urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
|
33
|
-
return {
|
34
|
-
href: urlParsingNode.href,
|
35
|
-
protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
|
36
|
-
host: urlParsingNode.host,
|
37
|
-
search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
|
38
|
-
hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
|
39
|
-
hostname: urlParsingNode.hostname,
|
40
|
-
port: urlParsingNode.port,
|
41
|
-
pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
|
42
|
-
urlParsingNode.pathname :
|
43
|
-
'/' + urlParsingNode.pathname
|
44
|
-
};
|
45
|
-
}
|
46
|
-
|
47
|
-
originURL = resolveURL(window.location.href);
|
48
|
-
|
49
|
-
/**
|
50
|
-
* Determine if a URL shares the same origin as the current location
|
51
|
-
*
|
52
|
-
* @param {String} requestURL The URL to test
|
53
|
-
* @returns {boolean} True if URL shares the same origin, otherwise false
|
54
|
-
*/
|
55
|
-
return function isURLSameOrigin(requestURL) {
|
56
|
-
const parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
|
57
|
-
return (parsed.protocol === originURL.protocol &&
|
58
|
-
parsed.host === originURL.host);
|
59
|
-
};
|
60
|
-
})() :
|
61
|
-
|
62
|
-
// Non standard browser envs (web workers, react-native) lack needed support.
|
63
|
-
(function nonStandardBrowserEnv() {
|
64
|
-
return function isURLSameOrigin() {
|
65
|
-
return true;
|
66
|
-
};
|
67
|
-
})();
|
3
|
+
export default platform.hasStandardBrowserEnv ? ((origin, isMSIE) => (url) => {
|
4
|
+
url = new URL(url, platform.origin);
|
5
|
+
|
6
|
+
return (
|
7
|
+
origin.protocol === url.protocol &&
|
8
|
+
origin.host === url.host &&
|
9
|
+
(isMSIE || origin.port === url.port)
|
10
|
+
);
|
11
|
+
})(
|
12
|
+
new URL(platform.origin),
|
13
|
+
platform.navigator && /(msie|trident)/i.test(platform.navigator.userAgent)
|
14
|
+
) : () => true;
|
package/lib/helpers/validator.js
CHANGED
@@ -52,6 +52,14 @@ validators.transitional = function transitional(validator, version, message) {
|
|
52
52
|
};
|
53
53
|
};
|
54
54
|
|
55
|
+
validators.spelling = function spelling(correctSpelling) {
|
56
|
+
return (value, opt) => {
|
57
|
+
// eslint-disable-next-line no-console
|
58
|
+
console.warn(`${opt} is likely a misspelling of ${correctSpelling}`);
|
59
|
+
return true;
|
60
|
+
}
|
61
|
+
};
|
62
|
+
|
55
63
|
/**
|
56
64
|
* Assert object's properties type
|
57
65
|
*
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "axios",
|
3
|
-
"version": "1.7.
|
3
|
+
"version": "1.7.9",
|
4
4
|
"description": "Promise based HTTP client for the browser and node.js",
|
5
5
|
"main": "index.js",
|
6
6
|
"exports": {
|
@@ -163,12 +163,12 @@
|
|
163
163
|
"Dmitriy Mozgovoy (https://github.com/DigitalBrainJS)",
|
164
164
|
"Jay (https://github.com/jasonsaayman)",
|
165
165
|
"Emily Morehouse (https://github.com/emilyemorehouse)",
|
166
|
-
"Rubén Norte (https://github.com/rubennorte)",
|
167
166
|
"Justin Beckwith (https://github.com/JustinBeckwith)",
|
167
|
+
"Rubén Norte (https://github.com/rubennorte)",
|
168
168
|
"Martti Laine (https://github.com/codeclown)",
|
169
169
|
"Xianming Zhong (https://github.com/chinesedfan)",
|
170
|
-
"Rikki Gibson (https://github.com/RikkiGibson)",
|
171
170
|
"Remco Haszing (https://github.com/remcohaszing)",
|
171
|
+
"Rikki Gibson (https://github.com/RikkiGibson)",
|
172
172
|
"Yasu Flores (https://github.com/yasuf)",
|
173
173
|
"Ben Carp (https://github.com/carpben)"
|
174
174
|
],
|