axios 0.21.1 → 0.21.2
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.
- package/CHANGELOG.md +76 -8
- package/README.md +74 -6
- package/SECURITY.md +5 -0
- package/dist/axios.js +2013 -1591
- package/dist/axios.map +1 -1
- package/dist/axios.min.js +2 -2
- package/dist/axios.min.map +1 -1
- package/index.d.ts +8 -1
- package/lib/adapters/http.js +33 -5
- package/lib/adapters/xhr.js +35 -25
- package/lib/core/Axios.js +60 -7
- package/lib/core/InterceptorManager.js +4 -2
- package/lib/core/README.md +1 -0
- package/lib/core/dispatchRequest.js +6 -3
- package/lib/core/transformData.js +3 -1
- package/lib/defaults.js +27 -6
- package/lib/helpers/validator.js +105 -0
- package/lib/utils.js +1 -3
- package/package.json +19 -21
package/lib/adapters/http.js
CHANGED
@@ -54,9 +54,16 @@ module.exports = function httpAdapter(config) {
|
|
54
54
|
var headers = config.headers;
|
55
55
|
|
56
56
|
// Set User-Agent (required by some servers)
|
57
|
-
// Only set header if it hasn't been set in config
|
58
57
|
// See https://github.com/axios/axios/issues/69
|
59
|
-
if (
|
58
|
+
if ('User-Agent' in headers || 'user-agent' in headers) {
|
59
|
+
// User-Agent is specified; handle case where no UA header is desired
|
60
|
+
if (!headers['User-Agent'] && !headers['user-agent']) {
|
61
|
+
delete headers['User-Agent'];
|
62
|
+
delete headers['user-agent'];
|
63
|
+
}
|
64
|
+
// Otherwise, use specified value
|
65
|
+
} else {
|
66
|
+
// Only set header if it hasn't been set in config
|
60
67
|
headers['User-Agent'] = 'axios/' + pkg.version;
|
61
68
|
}
|
62
69
|
|
@@ -231,11 +238,13 @@ module.exports = function httpAdapter(config) {
|
|
231
238
|
settle(resolve, reject, response);
|
232
239
|
} else {
|
233
240
|
var responseBuffer = [];
|
241
|
+
var totalResponseBytes = 0;
|
234
242
|
stream.on('data', function handleStreamData(chunk) {
|
235
243
|
responseBuffer.push(chunk);
|
244
|
+
totalResponseBytes += chunk.length;
|
236
245
|
|
237
246
|
// make sure the content length is not over the maxContentLength if specified
|
238
|
-
if (config.maxContentLength > -1 &&
|
247
|
+
if (config.maxContentLength > -1 && totalResponseBytes > config.maxContentLength) {
|
239
248
|
stream.destroy();
|
240
249
|
reject(createError('maxContentLength size of ' + config.maxContentLength + ' exceeded',
|
241
250
|
config, null, lastRequest));
|
@@ -270,14 +279,33 @@ module.exports = function httpAdapter(config) {
|
|
270
279
|
|
271
280
|
// Handle request timeout
|
272
281
|
if (config.timeout) {
|
282
|
+
// This is forcing a int timeout to avoid problems if the `req` interface doesn't handle other types.
|
283
|
+
var timeout = parseInt(config.timeout, 10);
|
284
|
+
|
285
|
+
if (isNaN(timeout)) {
|
286
|
+
reject(createError(
|
287
|
+
'error trying to parse `config.timeout` to int',
|
288
|
+
config,
|
289
|
+
'ERR_PARSE_TIMEOUT',
|
290
|
+
req
|
291
|
+
));
|
292
|
+
|
293
|
+
return;
|
294
|
+
}
|
295
|
+
|
273
296
|
// Sometime, the response will be very slow, and does not respond, the connect event will be block by event loop system.
|
274
297
|
// And timer callback will be fired, and abort() will be invoked before connection, then get "socket hang up" and code ECONNRESET.
|
275
298
|
// At this time, if we have a large number of request, nodejs will hang up some socket on background. and the number will up and up.
|
276
299
|
// And then these socket which be hang up will devoring CPU little by little.
|
277
300
|
// ClientRequest.setTimeout will be fired on the specify milliseconds, and can make sure that abort() will be fired after connect.
|
278
|
-
req.setTimeout(
|
301
|
+
req.setTimeout(timeout, function handleRequestTimeout() {
|
279
302
|
req.abort();
|
280
|
-
reject(createError(
|
303
|
+
reject(createError(
|
304
|
+
'timeout of ' + timeout + 'ms exceeded',
|
305
|
+
config,
|
306
|
+
config.transitional && config.transitional.clarifyTimeoutError ? 'ETIMEDOUT' : 'ECONNABORTED',
|
307
|
+
req
|
308
|
+
));
|
281
309
|
});
|
282
310
|
}
|
283
311
|
|
package/lib/adapters/xhr.js
CHANGED
@@ -13,6 +13,7 @@ module.exports = function xhrAdapter(config) {
|
|
13
13
|
return new Promise(function dispatchXhrRequest(resolve, reject) {
|
14
14
|
var requestData = config.data;
|
15
15
|
var requestHeaders = config.headers;
|
16
|
+
var responseType = config.responseType;
|
16
17
|
|
17
18
|
if (utils.isFormData(requestData)) {
|
18
19
|
delete requestHeaders['Content-Type']; // Let the browser set it
|
@@ -33,23 +34,14 @@ module.exports = function xhrAdapter(config) {
|
|
33
34
|
// Set the request timeout in MS
|
34
35
|
request.timeout = config.timeout;
|
35
36
|
|
36
|
-
|
37
|
-
|
38
|
-
if (!request || request.readyState !== 4) {
|
39
|
-
return;
|
40
|
-
}
|
41
|
-
|
42
|
-
// The request errored out and we didn't get a response, this will be
|
43
|
-
// handled by onerror instead
|
44
|
-
// With one exception: request that using file: protocol, most browsers
|
45
|
-
// will return status as 0 even though it's a successful request
|
46
|
-
if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
|
37
|
+
function onloadend() {
|
38
|
+
if (!request) {
|
47
39
|
return;
|
48
40
|
}
|
49
|
-
|
50
41
|
// Prepare the response
|
51
42
|
var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;
|
52
|
-
var responseData = !
|
43
|
+
var responseData = !responseType || responseType === 'text' || responseType === 'json' ?
|
44
|
+
request.responseText : request.response;
|
53
45
|
var response = {
|
54
46
|
data: responseData,
|
55
47
|
status: request.status,
|
@@ -63,7 +55,30 @@ module.exports = function xhrAdapter(config) {
|
|
63
55
|
|
64
56
|
// Clean up request
|
65
57
|
request = null;
|
66
|
-
}
|
58
|
+
}
|
59
|
+
|
60
|
+
if ('onloadend' in request) {
|
61
|
+
// Use onloadend if available
|
62
|
+
request.onloadend = onloadend;
|
63
|
+
} else {
|
64
|
+
// Listen for ready state to emulate onloadend
|
65
|
+
request.onreadystatechange = function handleLoad() {
|
66
|
+
if (!request || request.readyState !== 4) {
|
67
|
+
return;
|
68
|
+
}
|
69
|
+
|
70
|
+
// The request errored out and we didn't get a response, this will be
|
71
|
+
// handled by onerror instead
|
72
|
+
// With one exception: request that using file: protocol, most browsers
|
73
|
+
// will return status as 0 even though it's a successful request
|
74
|
+
if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
|
75
|
+
return;
|
76
|
+
}
|
77
|
+
// readystate handler is calling before onerror or ontimeout handlers,
|
78
|
+
// so we should call onloadend on the next 'tick'
|
79
|
+
setTimeout(onloadend);
|
80
|
+
};
|
81
|
+
}
|
67
82
|
|
68
83
|
// Handle browser request cancellation (as opposed to a manual cancellation)
|
69
84
|
request.onabort = function handleAbort() {
|
@@ -93,7 +108,10 @@ module.exports = function xhrAdapter(config) {
|
|
93
108
|
if (config.timeoutErrorMessage) {
|
94
109
|
timeoutErrorMessage = config.timeoutErrorMessage;
|
95
110
|
}
|
96
|
-
reject(createError(
|
111
|
+
reject(createError(
|
112
|
+
timeoutErrorMessage,
|
113
|
+
config,
|
114
|
+
config.transitional && config.transitional.clarifyTimeoutError ? 'ETIMEDOUT' : 'ECONNABORTED',
|
97
115
|
request));
|
98
116
|
|
99
117
|
// Clean up request
|
@@ -133,16 +151,8 @@ module.exports = function xhrAdapter(config) {
|
|
133
151
|
}
|
134
152
|
|
135
153
|
// Add responseType to request if needed
|
136
|
-
if (
|
137
|
-
|
138
|
-
request.responseType = config.responseType;
|
139
|
-
} catch (e) {
|
140
|
-
// Expected DOMException thrown by browsers not compatible XMLHttpRequest Level 2.
|
141
|
-
// But, this can be suppressed for 'json' type as it can be parsed by default 'transformResponse' function.
|
142
|
-
if (config.responseType !== 'json') {
|
143
|
-
throw e;
|
144
|
-
}
|
145
|
-
}
|
154
|
+
if (responseType && responseType !== 'json') {
|
155
|
+
request.responseType = config.responseType;
|
146
156
|
}
|
147
157
|
|
148
158
|
// Handle progress if needed
|
package/lib/core/Axios.js
CHANGED
@@ -5,7 +5,9 @@ var buildURL = require('../helpers/buildURL');
|
|
5
5
|
var InterceptorManager = require('./InterceptorManager');
|
6
6
|
var dispatchRequest = require('./dispatchRequest');
|
7
7
|
var mergeConfig = require('./mergeConfig');
|
8
|
+
var validator = require('../helpers/validator');
|
8
9
|
|
10
|
+
var validators = validator.validators;
|
9
11
|
/**
|
10
12
|
* Create a new instance of Axios
|
11
13
|
*
|
@@ -45,20 +47,71 @@ Axios.prototype.request = function request(config) {
|
|
45
47
|
config.method = 'get';
|
46
48
|
}
|
47
49
|
|
48
|
-
|
49
|
-
var chain = [dispatchRequest, undefined];
|
50
|
-
var promise = Promise.resolve(config);
|
50
|
+
var transitional = config.transitional;
|
51
51
|
|
52
|
+
if (transitional !== undefined) {
|
53
|
+
validator.assertOptions(transitional, {
|
54
|
+
silentJSONParsing: validators.transitional(validators.boolean, '1.0.0'),
|
55
|
+
forcedJSONParsing: validators.transitional(validators.boolean, '1.0.0'),
|
56
|
+
clarifyTimeoutError: validators.transitional(validators.boolean, '1.0.0')
|
57
|
+
}, false);
|
58
|
+
}
|
59
|
+
|
60
|
+
// filter out skipped interceptors
|
61
|
+
var requestInterceptorChain = [];
|
62
|
+
var synchronousRequestInterceptors = true;
|
52
63
|
this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
|
53
|
-
|
64
|
+
if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) {
|
65
|
+
return;
|
66
|
+
}
|
67
|
+
|
68
|
+
synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
|
69
|
+
|
70
|
+
requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
|
54
71
|
});
|
55
72
|
|
73
|
+
var responseInterceptorChain = [];
|
56
74
|
this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
|
57
|
-
|
75
|
+
responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
|
58
76
|
});
|
59
77
|
|
60
|
-
|
61
|
-
|
78
|
+
var promise;
|
79
|
+
|
80
|
+
if (!synchronousRequestInterceptors) {
|
81
|
+
var chain = [dispatchRequest, undefined];
|
82
|
+
|
83
|
+
Array.prototype.unshift.apply(chain, requestInterceptorChain);
|
84
|
+
chain.concat(responseInterceptorChain);
|
85
|
+
|
86
|
+
promise = Promise.resolve(config);
|
87
|
+
while (chain.length) {
|
88
|
+
promise = promise.then(chain.shift(), chain.shift());
|
89
|
+
}
|
90
|
+
|
91
|
+
return promise;
|
92
|
+
}
|
93
|
+
|
94
|
+
|
95
|
+
var newConfig = config;
|
96
|
+
while (requestInterceptorChain.length) {
|
97
|
+
var onFulfilled = requestInterceptorChain.shift();
|
98
|
+
var onRejected = requestInterceptorChain.shift();
|
99
|
+
try {
|
100
|
+
newConfig = onFulfilled(newConfig);
|
101
|
+
} catch (error) {
|
102
|
+
onRejected(error);
|
103
|
+
break;
|
104
|
+
}
|
105
|
+
}
|
106
|
+
|
107
|
+
try {
|
108
|
+
promise = dispatchRequest(newConfig);
|
109
|
+
} catch (error) {
|
110
|
+
return Promise.reject(error);
|
111
|
+
}
|
112
|
+
|
113
|
+
while (responseInterceptorChain.length) {
|
114
|
+
promise = promise.then(responseInterceptorChain.shift(), responseInterceptorChain.shift());
|
62
115
|
}
|
63
116
|
|
64
117
|
return promise;
|
@@ -14,10 +14,12 @@ function InterceptorManager() {
|
|
14
14
|
*
|
15
15
|
* @return {Number} An ID used to remove interceptor later
|
16
16
|
*/
|
17
|
-
InterceptorManager.prototype.use = function use(fulfilled, rejected) {
|
17
|
+
InterceptorManager.prototype.use = function use(fulfilled, rejected, options) {
|
18
18
|
this.handlers.push({
|
19
19
|
fulfilled: fulfilled,
|
20
|
-
rejected: rejected
|
20
|
+
rejected: rejected,
|
21
|
+
synchronous: options ? options.synchronous : false,
|
22
|
+
runWhen: options ? options.runWhen : null
|
21
23
|
});
|
22
24
|
return this.handlers.length - 1;
|
23
25
|
};
|
package/lib/core/README.md
CHANGED
@@ -3,5 +3,6 @@
|
|
3
3
|
The modules found in `core/` should be modules that are specific to the domain logic of axios. These modules would most likely not make sense to be consumed outside of the axios module, as their logic is too specific. Some examples of core modules are:
|
4
4
|
|
5
5
|
- Dispatching requests
|
6
|
+
- Requests sent via `adapters/` (see lib/adapters/README.md)
|
6
7
|
- Managing interceptors
|
7
8
|
- Handling config
|
@@ -27,7 +27,8 @@ module.exports = function dispatchRequest(config) {
|
|
27
27
|
config.headers = config.headers || {};
|
28
28
|
|
29
29
|
// Transform request data
|
30
|
-
config.data = transformData(
|
30
|
+
config.data = transformData.call(
|
31
|
+
config,
|
31
32
|
config.data,
|
32
33
|
config.headers,
|
33
34
|
config.transformRequest
|
@@ -53,7 +54,8 @@ module.exports = function dispatchRequest(config) {
|
|
53
54
|
throwIfCancellationRequested(config);
|
54
55
|
|
55
56
|
// Transform response data
|
56
|
-
response.data = transformData(
|
57
|
+
response.data = transformData.call(
|
58
|
+
config,
|
57
59
|
response.data,
|
58
60
|
response.headers,
|
59
61
|
config.transformResponse
|
@@ -66,7 +68,8 @@ module.exports = function dispatchRequest(config) {
|
|
66
68
|
|
67
69
|
// Transform response data
|
68
70
|
if (reason && reason.response) {
|
69
|
-
reason.response.data = transformData(
|
71
|
+
reason.response.data = transformData.call(
|
72
|
+
config,
|
70
73
|
reason.response.data,
|
71
74
|
reason.response.headers,
|
72
75
|
config.transformResponse
|
@@ -1,6 +1,7 @@
|
|
1
1
|
'use strict';
|
2
2
|
|
3
3
|
var utils = require('./../utils');
|
4
|
+
var defaults = require('./../defaults');
|
4
5
|
|
5
6
|
/**
|
6
7
|
* Transform the data for a request or a response
|
@@ -11,9 +12,10 @@ var utils = require('./../utils');
|
|
11
12
|
* @returns {*} The resulting transformed data
|
12
13
|
*/
|
13
14
|
module.exports = function transformData(data, headers, fns) {
|
15
|
+
var context = this || defaults;
|
14
16
|
/*eslint no-param-reassign:0*/
|
15
17
|
utils.forEach(fns, function transform(fn) {
|
16
|
-
data = fn(data, headers);
|
18
|
+
data = fn.call(context, data, headers);
|
17
19
|
});
|
18
20
|
|
19
21
|
return data;
|
package/lib/defaults.js
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
var utils = require('./utils');
|
4
4
|
var normalizeHeaderName = require('./helpers/normalizeHeaderName');
|
5
|
+
var enhanceError = require('./core/enhanceError');
|
5
6
|
|
6
7
|
var DEFAULT_CONTENT_TYPE = {
|
7
8
|
'Content-Type': 'application/x-www-form-urlencoded'
|
@@ -26,11 +27,19 @@ function getDefaultAdapter() {
|
|
26
27
|
}
|
27
28
|
|
28
29
|
var defaults = {
|
30
|
+
|
31
|
+
transitional: {
|
32
|
+
silentJSONParsing: true,
|
33
|
+
forcedJSONParsing: true,
|
34
|
+
clarifyTimeoutError: false
|
35
|
+
},
|
36
|
+
|
29
37
|
adapter: getDefaultAdapter(),
|
30
38
|
|
31
39
|
transformRequest: [function transformRequest(data, headers) {
|
32
40
|
normalizeHeaderName(headers, 'Accept');
|
33
41
|
normalizeHeaderName(headers, 'Content-Type');
|
42
|
+
|
34
43
|
if (utils.isFormData(data) ||
|
35
44
|
utils.isArrayBuffer(data) ||
|
36
45
|
utils.isBuffer(data) ||
|
@@ -47,20 +56,32 @@ var defaults = {
|
|
47
56
|
setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');
|
48
57
|
return data.toString();
|
49
58
|
}
|
50
|
-
if (utils.isObject(data)) {
|
51
|
-
setContentTypeIfUnset(headers, 'application/json
|
59
|
+
if (utils.isObject(data) || (headers && headers['Content-Type'] === 'application/json')) {
|
60
|
+
setContentTypeIfUnset(headers, 'application/json');
|
52
61
|
return JSON.stringify(data);
|
53
62
|
}
|
54
63
|
return data;
|
55
64
|
}],
|
56
65
|
|
57
66
|
transformResponse: [function transformResponse(data) {
|
58
|
-
|
59
|
-
|
67
|
+
var transitional = this.transitional;
|
68
|
+
var silentJSONParsing = transitional && transitional.silentJSONParsing;
|
69
|
+
var forcedJSONParsing = transitional && transitional.forcedJSONParsing;
|
70
|
+
var strictJSONParsing = !silentJSONParsing && this.responseType === 'json';
|
71
|
+
|
72
|
+
if (strictJSONParsing || (forcedJSONParsing && utils.isString(data) && data.length)) {
|
60
73
|
try {
|
61
|
-
|
62
|
-
} catch (e) {
|
74
|
+
return JSON.parse(data);
|
75
|
+
} catch (e) {
|
76
|
+
if (strictJSONParsing) {
|
77
|
+
if (e.name === 'SyntaxError') {
|
78
|
+
throw enhanceError(e, this, 'E_JSON_PARSE');
|
79
|
+
}
|
80
|
+
throw e;
|
81
|
+
}
|
82
|
+
}
|
63
83
|
}
|
84
|
+
|
64
85
|
return data;
|
65
86
|
}],
|
66
87
|
|
@@ -0,0 +1,105 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
var pkg = require('./../../package.json');
|
4
|
+
|
5
|
+
var validators = {};
|
6
|
+
|
7
|
+
// eslint-disable-next-line func-names
|
8
|
+
['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach(function(type, i) {
|
9
|
+
validators[type] = function validator(thing) {
|
10
|
+
return typeof thing === type || 'a' + (i < 1 ? 'n ' : ' ') + type;
|
11
|
+
};
|
12
|
+
});
|
13
|
+
|
14
|
+
var deprecatedWarnings = {};
|
15
|
+
var currentVerArr = pkg.version.split('.');
|
16
|
+
|
17
|
+
/**
|
18
|
+
* Compare package versions
|
19
|
+
* @param {string} version
|
20
|
+
* @param {string?} thanVersion
|
21
|
+
* @returns {boolean}
|
22
|
+
*/
|
23
|
+
function isOlderVersion(version, thanVersion) {
|
24
|
+
var pkgVersionArr = thanVersion ? thanVersion.split('.') : currentVerArr;
|
25
|
+
var destVer = version.split('.');
|
26
|
+
for (var i = 0; i < 3; i++) {
|
27
|
+
if (pkgVersionArr[i] > destVer[i]) {
|
28
|
+
return true;
|
29
|
+
} else if (pkgVersionArr[i] < destVer[i]) {
|
30
|
+
return false;
|
31
|
+
}
|
32
|
+
}
|
33
|
+
return false;
|
34
|
+
}
|
35
|
+
|
36
|
+
/**
|
37
|
+
* Transitional option validator
|
38
|
+
* @param {function|boolean?} validator
|
39
|
+
* @param {string?} version
|
40
|
+
* @param {string} message
|
41
|
+
* @returns {function}
|
42
|
+
*/
|
43
|
+
validators.transitional = function transitional(validator, version, message) {
|
44
|
+
var isDeprecated = version && isOlderVersion(version);
|
45
|
+
|
46
|
+
function formatMessage(opt, desc) {
|
47
|
+
return '[Axios v' + pkg.version + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
|
48
|
+
}
|
49
|
+
|
50
|
+
// eslint-disable-next-line func-names
|
51
|
+
return function(value, opt, opts) {
|
52
|
+
if (validator === false) {
|
53
|
+
throw new Error(formatMessage(opt, ' has been removed in ' + version));
|
54
|
+
}
|
55
|
+
|
56
|
+
if (isDeprecated && !deprecatedWarnings[opt]) {
|
57
|
+
deprecatedWarnings[opt] = true;
|
58
|
+
// eslint-disable-next-line no-console
|
59
|
+
console.warn(
|
60
|
+
formatMessage(
|
61
|
+
opt,
|
62
|
+
' has been deprecated since v' + version + ' and will be removed in the near future'
|
63
|
+
)
|
64
|
+
);
|
65
|
+
}
|
66
|
+
|
67
|
+
return validator ? validator(value, opt, opts) : true;
|
68
|
+
};
|
69
|
+
};
|
70
|
+
|
71
|
+
/**
|
72
|
+
* Assert object's properties type
|
73
|
+
* @param {object} options
|
74
|
+
* @param {object} schema
|
75
|
+
* @param {boolean?} allowUnknown
|
76
|
+
*/
|
77
|
+
|
78
|
+
function assertOptions(options, schema, allowUnknown) {
|
79
|
+
if (typeof options !== 'object') {
|
80
|
+
throw new TypeError('options must be an object');
|
81
|
+
}
|
82
|
+
var keys = Object.keys(options);
|
83
|
+
var i = keys.length;
|
84
|
+
while (i-- > 0) {
|
85
|
+
var opt = keys[i];
|
86
|
+
var validator = schema[opt];
|
87
|
+
if (validator) {
|
88
|
+
var value = options[opt];
|
89
|
+
var result = value === undefined || validator(value, opt, options);
|
90
|
+
if (result !== true) {
|
91
|
+
throw new TypeError('option ' + opt + ' must be ' + result);
|
92
|
+
}
|
93
|
+
continue;
|
94
|
+
}
|
95
|
+
if (allowUnknown !== true) {
|
96
|
+
throw Error('Unknown option ' + opt);
|
97
|
+
}
|
98
|
+
}
|
99
|
+
}
|
100
|
+
|
101
|
+
module.exports = {
|
102
|
+
isOlderVersion: isOlderVersion,
|
103
|
+
assertOptions: assertOptions,
|
104
|
+
validators: validators
|
105
|
+
};
|
package/lib/utils.js
CHANGED
@@ -2,8 +2,6 @@
|
|
2
2
|
|
3
3
|
var bind = require('./helpers/bind');
|
4
4
|
|
5
|
-
/*global toString:true*/
|
6
|
-
|
7
5
|
// utils is a library of generic helper functions non-specific to axios
|
8
6
|
|
9
7
|
var toString = Object.prototype.toString;
|
@@ -187,7 +185,7 @@ function isURLSearchParams(val) {
|
|
187
185
|
* @returns {String} The String freed of excess whitespace
|
188
186
|
*/
|
189
187
|
function trim(str) {
|
190
|
-
return str.
|
188
|
+
return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g, '');
|
191
189
|
}
|
192
190
|
|
193
191
|
/**
|
package/package.json
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
{
|
2
2
|
"name": "axios",
|
3
|
-
"version": "0.21.
|
3
|
+
"version": "0.21.2",
|
4
4
|
"description": "Promise based HTTP client for the browser and node.js",
|
5
5
|
"main": "index.js",
|
6
6
|
"scripts": {
|
7
|
-
"test": "grunt test
|
7
|
+
"test": "grunt test",
|
8
8
|
"start": "node ./sandbox/server.js",
|
9
9
|
"build": "NODE_ENV=production grunt build",
|
10
10
|
"preversion": "npm test",
|
@@ -30,43 +30,41 @@
|
|
30
30
|
"bugs": {
|
31
31
|
"url": "https://github.com/axios/axios/issues"
|
32
32
|
},
|
33
|
-
"homepage": "https://
|
33
|
+
"homepage": "https://axios-http.com",
|
34
34
|
"devDependencies": {
|
35
|
-
"bundlesize": "^0.17.0",
|
36
35
|
"coveralls": "^3.0.0",
|
37
36
|
"es6-promise": "^4.2.4",
|
38
|
-
"grunt": "^1.0
|
37
|
+
"grunt": "^1.3.0",
|
39
38
|
"grunt-banner": "^0.6.0",
|
40
39
|
"grunt-cli": "^1.2.0",
|
41
40
|
"grunt-contrib-clean": "^1.1.0",
|
42
41
|
"grunt-contrib-watch": "^1.0.0",
|
43
|
-
"grunt-eslint": "^
|
44
|
-
"grunt-karma": "^
|
42
|
+
"grunt-eslint": "^23.0.0",
|
43
|
+
"grunt-karma": "^4.0.0",
|
45
44
|
"grunt-mocha-test": "^0.13.3",
|
46
45
|
"grunt-ts": "^6.0.0-beta.19",
|
47
|
-
"grunt-webpack": "^
|
46
|
+
"grunt-webpack": "^4.0.2",
|
48
47
|
"istanbul-instrumenter-loader": "^1.0.0",
|
49
48
|
"jasmine-core": "^2.4.1",
|
50
|
-
"karma": "^
|
51
|
-
"karma-chrome-launcher": "^
|
52
|
-
"karma-
|
53
|
-
"karma-firefox-launcher": "^1.1.0",
|
49
|
+
"karma": "^6.3.2",
|
50
|
+
"karma-chrome-launcher": "^3.1.0",
|
51
|
+
"karma-firefox-launcher": "^2.1.0",
|
54
52
|
"karma-jasmine": "^1.1.1",
|
55
53
|
"karma-jasmine-ajax": "^0.1.13",
|
56
|
-
"karma-opera-launcher": "^1.0.0",
|
57
54
|
"karma-safari-launcher": "^1.0.0",
|
58
|
-
"karma-sauce-launcher": "^
|
55
|
+
"karma-sauce-launcher": "^4.3.6",
|
59
56
|
"karma-sinon": "^1.0.5",
|
60
|
-
"karma-sourcemap-loader": "^0.3.
|
61
|
-
"karma-webpack": "^
|
57
|
+
"karma-sourcemap-loader": "^0.3.8",
|
58
|
+
"karma-webpack": "^4.0.2",
|
62
59
|
"load-grunt-tasks": "^3.5.2",
|
63
60
|
"minimist": "^1.2.0",
|
64
|
-
"mocha": "^
|
61
|
+
"mocha": "^8.2.1",
|
65
62
|
"sinon": "^4.5.0",
|
66
|
-
"
|
63
|
+
"terser-webpack-plugin": "^4.2.3",
|
64
|
+
"typescript": "^4.0.5",
|
67
65
|
"url-search-params": "^0.10.0",
|
68
|
-
"webpack": "^
|
69
|
-
"webpack-dev-server": "^
|
66
|
+
"webpack": "^4.44.2",
|
67
|
+
"webpack-dev-server": "^3.11.0"
|
70
68
|
},
|
71
69
|
"browser": {
|
72
70
|
"./lib/adapters/http.js": "./lib/adapters/xhr.js"
|
@@ -75,7 +73,7 @@
|
|
75
73
|
"unpkg": "dist/axios.min.js",
|
76
74
|
"typings": "./index.d.ts",
|
77
75
|
"dependencies": {
|
78
|
-
"follow-redirects": "^1.
|
76
|
+
"follow-redirects": "^1.14.0"
|
79
77
|
},
|
80
78
|
"bundlesize": [
|
81
79
|
{
|