axios 1.1.1 → 1.1.3
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 +46 -1
- package/README.md +100 -16
- package/dist/axios.js +226 -491
- package/dist/axios.js.map +1 -1
- package/dist/axios.min.js +1 -1
- package/dist/axios.min.js.map +1 -1
- package/dist/esm/axios.js +33 -25
- 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 +38 -29
- package/dist/node/axios.cjs.map +1 -1
- package/index.d.ts +7 -2
- package/index.js +30 -0
- package/lib/adapters/http.js +7 -4
- package/lib/core/Axios.js +8 -1
- package/lib/core/AxiosHeaders.js +4 -10
- package/lib/env/data.js +1 -1
- package/lib/helpers/buildURL.js +17 -10
- package/lib/helpers/toFormData.js +2 -2
- package/package.json +3 -2
- package/rollup.config.js +1 -1
package/dist/node/axios.cjs
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
// Axios v1.1.
|
1
|
+
// Axios v1.1.3 Copyright (c) 2022 Matt Zabriskie and contributors
|
2
2
|
'use strict';
|
3
3
|
|
4
4
|
const FormData$1 = require('form-data');
|
@@ -897,7 +897,7 @@ function toFormData(obj, formData, options) {
|
|
897
897
|
key = removeBrackets(key);
|
898
898
|
|
899
899
|
arr.forEach(function each(el, index) {
|
900
|
-
!utils.isUndefined(el) && formData.append(
|
900
|
+
!(utils.isUndefined(el) || el === null) && formData.append(
|
901
901
|
// eslint-disable-next-line no-nested-ternary
|
902
902
|
indexes === true ? renderKey([key], index, dots) : (indexes === null ? key : key + '[]'),
|
903
903
|
convertValue(el)
|
@@ -934,7 +934,7 @@ function toFormData(obj, formData, options) {
|
|
934
934
|
stack.push(value);
|
935
935
|
|
936
936
|
utils.forEach(value, function each(el, key) {
|
937
|
-
const result = !utils.isUndefined(el) && visitor.call(
|
937
|
+
const result = !(utils.isUndefined(el) || el === null) && visitor.call(
|
938
938
|
formData, el, utils.isString(key) ? key.trim() : key, path, exposedHelpers
|
939
939
|
);
|
940
940
|
|
@@ -1040,21 +1040,28 @@ function buildURL(url, params, options) {
|
|
1040
1040
|
if (!params) {
|
1041
1041
|
return url;
|
1042
1042
|
}
|
1043
|
+
|
1044
|
+
const _encode = options && options.encode || encode;
|
1043
1045
|
|
1044
|
-
const
|
1046
|
+
const serializeFn = options && options.serialize;
|
1045
1047
|
|
1046
|
-
|
1047
|
-
url = url.slice(0, hashmarkIndex);
|
1048
|
-
}
|
1048
|
+
let serializedParams;
|
1049
1049
|
|
1050
|
-
|
1050
|
+
if (serializeFn) {
|
1051
|
+
serializedParams = serializeFn(params, options);
|
1052
|
+
} else {
|
1053
|
+
serializedParams = utils.isURLSearchParams(params) ?
|
1054
|
+
params.toString() :
|
1055
|
+
new AxiosURLSearchParams(params, options).toString(_encode);
|
1056
|
+
}
|
1051
1057
|
|
1052
|
-
|
1053
|
-
|
1054
|
-
new AxiosURLSearchParams(params, options).toString(_encode);
|
1058
|
+
if (serializedParams) {
|
1059
|
+
const hashmarkIndex = url.indexOf("#");
|
1055
1060
|
|
1056
|
-
|
1057
|
-
|
1061
|
+
if (hashmarkIndex !== -1) {
|
1062
|
+
url = url.slice(0, hashmarkIndex);
|
1063
|
+
}
|
1064
|
+
url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
|
1058
1065
|
}
|
1059
1066
|
|
1060
1067
|
return url;
|
@@ -1313,7 +1320,7 @@ function buildFullPath(baseURL, requestedURL) {
|
|
1313
1320
|
return requestedURL;
|
1314
1321
|
}
|
1315
1322
|
|
1316
|
-
const VERSION = "1.1.
|
1323
|
+
const VERSION = "1.1.3";
|
1317
1324
|
|
1318
1325
|
/**
|
1319
1326
|
* A `CanceledError` is an object that is thrown when an operation is canceled.
|
@@ -1451,7 +1458,7 @@ function normalizeValue(value) {
|
|
1451
1458
|
return value;
|
1452
1459
|
}
|
1453
1460
|
|
1454
|
-
return String(value);
|
1461
|
+
return utils.isArray(value) ? value.map(normalizeValue) : String(value);
|
1455
1462
|
}
|
1456
1463
|
|
1457
1464
|
function parseTokens(str) {
|
@@ -1538,13 +1545,7 @@ Object.assign(AxiosHeaders.prototype, {
|
|
1538
1545
|
return;
|
1539
1546
|
}
|
1540
1547
|
|
1541
|
-
|
1542
|
-
_value = _value.map(normalizeValue);
|
1543
|
-
} else {
|
1544
|
-
_value = normalizeValue(_value);
|
1545
|
-
}
|
1546
|
-
|
1547
|
-
self[key || _header] = _value;
|
1548
|
+
self[key || _header] = normalizeValue(_value);
|
1548
1549
|
}
|
1549
1550
|
|
1550
1551
|
if (utils.isPlainObject(header)) {
|
@@ -1658,13 +1659,13 @@ Object.assign(AxiosHeaders.prototype, {
|
|
1658
1659
|
return this;
|
1659
1660
|
},
|
1660
1661
|
|
1661
|
-
toJSON: function() {
|
1662
|
+
toJSON: function(asStrings) {
|
1662
1663
|
const obj = Object.create(null);
|
1663
1664
|
|
1664
1665
|
utils.forEach(Object.assign({}, this[$defaults] || null, this),
|
1665
1666
|
(value, header) => {
|
1666
1667
|
if (value == null || value === false) return;
|
1667
|
-
obj[header] = utils.isArray(value) ? value.join(', ') : value;
|
1668
|
+
obj[header] = asStrings && utils.isArray(value) ? value.join(', ') : value;
|
1668
1669
|
});
|
1669
1670
|
|
1670
1671
|
return obj;
|
@@ -2003,7 +2004,7 @@ function dispatchBeforeRedirect(options) {
|
|
2003
2004
|
* If the proxy or config afterRedirects functions are defined, call them with the options
|
2004
2005
|
*
|
2005
2006
|
* @param {http.ClientRequestArgs} options
|
2006
|
-
* @param {AxiosProxyConfig} configProxy
|
2007
|
+
* @param {AxiosProxyConfig} configProxy configuration from Axios options object
|
2007
2008
|
* @param {string} location
|
2008
2009
|
*
|
2009
2010
|
* @returns {http.ClientRequestArgs}
|
@@ -2034,13 +2035,14 @@ function setProxy(options, configProxy, location) {
|
|
2034
2035
|
}
|
2035
2036
|
|
2036
2037
|
options.headers.host = options.hostname + (options.port ? ':' + options.port : '');
|
2037
|
-
|
2038
|
+
const proxyHost = proxy.hostname || proxy.host;
|
2039
|
+
options.hostname = proxyHost;
|
2038
2040
|
// Replace 'host' since options is not a URL object
|
2039
|
-
options.host =
|
2041
|
+
options.host = proxyHost;
|
2040
2042
|
options.port = proxy.port;
|
2041
2043
|
options.path = location;
|
2042
2044
|
if (proxy.protocol) {
|
2043
|
-
options.protocol = proxy.protocol
|
2045
|
+
options.protocol = proxy.protocol.includes(':') ? proxy.protocol : `${proxy.protocol}:`;
|
2044
2046
|
}
|
2045
2047
|
}
|
2046
2048
|
|
@@ -3401,7 +3403,7 @@ class Axios {
|
|
3401
3403
|
|
3402
3404
|
config = mergeConfig(this.defaults, config);
|
3403
3405
|
|
3404
|
-
const transitional = config
|
3406
|
+
const {transitional, paramsSerializer} = config;
|
3405
3407
|
|
3406
3408
|
if (transitional !== undefined) {
|
3407
3409
|
validator.assertOptions(transitional, {
|
@@ -3411,6 +3413,13 @@ class Axios {
|
|
3411
3413
|
}, false);
|
3412
3414
|
}
|
3413
3415
|
|
3416
|
+
if (paramsSerializer !== undefined) {
|
3417
|
+
validator.assertOptions(paramsSerializer, {
|
3418
|
+
encode: validators.function,
|
3419
|
+
serialize: validators.function
|
3420
|
+
}, true);
|
3421
|
+
}
|
3422
|
+
|
3414
3423
|
// Set config.method
|
3415
3424
|
config.method = (config.method || this.defaults.method || 'get').toLowerCase();
|
3416
3425
|
|