axios 1.3.4 → 1.4.0
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 +50 -0
- package/dist/axios.js +34 -16
- 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 +38 -19
- package/dist/browser/axios.cjs.map +1 -1
- package/dist/esm/axios.js +38 -19
- 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 +67 -20
- package/dist/node/axios.cjs.map +1 -1
- package/index.d.cts +23 -19
- package/index.d.ts +7 -3
- package/lib/adapters/http.js +15 -1
- package/lib/adapters/xhr.js +6 -2
- package/lib/core/Axios.js +11 -5
- package/lib/core/AxiosHeaders.js +1 -3
- package/lib/core/mergeConfig.js +1 -1
- package/lib/env/data.js +1 -1
- package/lib/helpers/callbackify.js +16 -0
- package/lib/utils.js +17 -6
- package/package.json +13 -4
package/dist/node/axios.cjs
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
// Axios v1.
|
1
|
+
// Axios v1.4.0 Copyright (c) 2023 Matt Zabriskie and contributors
|
2
2
|
'use strict';
|
3
3
|
|
4
4
|
const FormData$1 = require('form-data');
|
@@ -216,12 +216,16 @@ const isStream = (val) => isObject(val) && isFunction(val.pipe);
|
|
216
216
|
* @returns {boolean} True if value is an FormData, otherwise false
|
217
217
|
*/
|
218
218
|
const isFormData = (thing) => {
|
219
|
-
|
219
|
+
let kind;
|
220
220
|
return thing && (
|
221
|
-
(typeof FormData === 'function' && thing instanceof FormData) ||
|
222
|
-
|
223
|
-
|
224
|
-
|
221
|
+
(typeof FormData === 'function' && thing instanceof FormData) || (
|
222
|
+
isFunction(thing.append) && (
|
223
|
+
(kind = kindOf(thing)) === 'formdata' ||
|
224
|
+
// detect form-data instance
|
225
|
+
(kind === 'object' && isFunction(thing.toString) && thing.toString() === '[object FormData]')
|
226
|
+
)
|
227
|
+
)
|
228
|
+
)
|
225
229
|
};
|
226
230
|
|
227
231
|
/**
|
@@ -686,6 +690,11 @@ const toJSONObject = (obj) => {
|
|
686
690
|
return visit(obj, 0);
|
687
691
|
};
|
688
692
|
|
693
|
+
const isAsyncFn = kindOfTest('AsyncFunction');
|
694
|
+
|
695
|
+
const isThenable = (thing) =>
|
696
|
+
thing && (isObject(thing) || isFunction(thing)) && isFunction(thing.then) && isFunction(thing.catch);
|
697
|
+
|
689
698
|
const utils = {
|
690
699
|
isArray,
|
691
700
|
isArrayBuffer,
|
@@ -735,7 +744,9 @@ const utils = {
|
|
735
744
|
ALPHABET,
|
736
745
|
generateString,
|
737
746
|
isSpecCompliantForm,
|
738
|
-
toJSONObject
|
747
|
+
toJSONObject,
|
748
|
+
isAsyncFn,
|
749
|
+
isThenable
|
739
750
|
};
|
740
751
|
|
741
752
|
/**
|
@@ -1577,9 +1588,7 @@ function parseTokens(str) {
|
|
1577
1588
|
return tokens;
|
1578
1589
|
}
|
1579
1590
|
|
1580
|
-
|
1581
|
-
return /^[-_a-zA-Z]+$/.test(str.trim());
|
1582
|
-
}
|
1591
|
+
const isValidHeaderName = (str) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
|
1583
1592
|
|
1584
1593
|
function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
|
1585
1594
|
if (utils.isFunction(filter)) {
|
@@ -1952,7 +1961,7 @@ function buildFullPath(baseURL, requestedURL) {
|
|
1952
1961
|
return requestedURL;
|
1953
1962
|
}
|
1954
1963
|
|
1955
|
-
const VERSION = "1.
|
1964
|
+
const VERSION = "1.4.0";
|
1956
1965
|
|
1957
1966
|
function parseProtocol(url) {
|
1958
1967
|
const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
|
@@ -2422,6 +2431,21 @@ class ZlibHeaderTransformStream extends stream__default["default"].Transform {
|
|
2422
2431
|
|
2423
2432
|
const ZlibHeaderTransformStream$1 = ZlibHeaderTransformStream;
|
2424
2433
|
|
2434
|
+
const callbackify = (fn, reducer) => {
|
2435
|
+
return utils.isAsyncFn(fn) ? function (...args) {
|
2436
|
+
const cb = args.pop();
|
2437
|
+
fn.apply(this, args).then((value) => {
|
2438
|
+
try {
|
2439
|
+
reducer ? cb(null, ...reducer(value)) : cb(null, value);
|
2440
|
+
} catch (err) {
|
2441
|
+
cb(err);
|
2442
|
+
}
|
2443
|
+
}, cb);
|
2444
|
+
} : fn;
|
2445
|
+
};
|
2446
|
+
|
2447
|
+
const callbackify$1 = callbackify;
|
2448
|
+
|
2425
2449
|
const zlibOptions = {
|
2426
2450
|
flush: zlib__default["default"].constants.Z_SYNC_FLUSH,
|
2427
2451
|
finishFlush: zlib__default["default"].constants.Z_SYNC_FLUSH
|
@@ -2544,13 +2568,24 @@ const wrapAsync = (asyncExecutor) => {
|
|
2544
2568
|
/*eslint consistent-return:0*/
|
2545
2569
|
const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
|
2546
2570
|
return wrapAsync(async function dispatchHttpRequest(resolve, reject, onDone) {
|
2547
|
-
let {data} = config;
|
2571
|
+
let {data, lookup, family} = config;
|
2548
2572
|
const {responseType, responseEncoding} = config;
|
2549
2573
|
const method = config.method.toUpperCase();
|
2550
2574
|
let isDone;
|
2551
2575
|
let rejected = false;
|
2552
2576
|
let req;
|
2553
2577
|
|
2578
|
+
if (lookup && utils.isAsyncFn(lookup)) {
|
2579
|
+
lookup = callbackify$1(lookup, (entry) => {
|
2580
|
+
if(utils.isString(entry)) {
|
2581
|
+
entry = [entry, entry.indexOf('.') < 0 ? 6 : 4];
|
2582
|
+
} else if (!utils.isArray(entry)) {
|
2583
|
+
throw new TypeError('lookup async function must return an array [ip: string, family: number]]')
|
2584
|
+
}
|
2585
|
+
return entry;
|
2586
|
+
});
|
2587
|
+
}
|
2588
|
+
|
2554
2589
|
// temporary internal emitter until the AxiosRequest class will be implemented
|
2555
2590
|
const emitter = new EventEmitter__default["default"]();
|
2556
2591
|
|
@@ -2774,6 +2809,8 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
|
|
2774
2809
|
agents: { http: config.httpAgent, https: config.httpsAgent },
|
2775
2810
|
auth,
|
2776
2811
|
protocol,
|
2812
|
+
family,
|
2813
|
+
lookup,
|
2777
2814
|
beforeRedirect: dispatchBeforeRedirect,
|
2778
2815
|
beforeRedirects: {}
|
2779
2816
|
};
|
@@ -3203,8 +3240,12 @@ const xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
3203
3240
|
}
|
3204
3241
|
}
|
3205
3242
|
|
3206
|
-
if (utils.isFormData(requestData)
|
3207
|
-
|
3243
|
+
if (utils.isFormData(requestData)) {
|
3244
|
+
if (platform.isStandardBrowserEnv || platform.isStandardBrowserWebWorkerEnv) {
|
3245
|
+
requestHeaders.setContentType(false); // Let the browser set it
|
3246
|
+
} else {
|
3247
|
+
requestHeaders.setContentType('multipart/form-data;', false); // mobile/desktop app frameworks
|
3248
|
+
}
|
3208
3249
|
}
|
3209
3250
|
|
3210
3251
|
let request = new XMLHttpRequest();
|
@@ -3610,7 +3651,7 @@ function mergeConfig(config1, config2) {
|
|
3610
3651
|
headers: (a, b) => mergeDeepProperties(headersToObject(a), headersToObject(b), true)
|
3611
3652
|
};
|
3612
3653
|
|
3613
|
-
utils.forEach(Object.keys(
|
3654
|
+
utils.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
|
3614
3655
|
const merge = mergeMap[prop] || mergeDeepProperties;
|
3615
3656
|
const configValue = merge(config1[prop], config2[prop], prop);
|
3616
3657
|
(utils.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
|
@@ -3754,11 +3795,17 @@ class Axios {
|
|
3754
3795
|
}, false);
|
3755
3796
|
}
|
3756
3797
|
|
3757
|
-
if (paramsSerializer
|
3758
|
-
|
3759
|
-
|
3760
|
-
|
3761
|
-
|
3798
|
+
if (paramsSerializer != null) {
|
3799
|
+
if (utils.isFunction(paramsSerializer)) {
|
3800
|
+
config.paramsSerializer = {
|
3801
|
+
serialize: paramsSerializer
|
3802
|
+
};
|
3803
|
+
} else {
|
3804
|
+
validator.assertOptions(paramsSerializer, {
|
3805
|
+
encode: validators.function,
|
3806
|
+
serialize: validators.function
|
3807
|
+
}, true);
|
3808
|
+
}
|
3762
3809
|
}
|
3763
3810
|
|
3764
3811
|
// Set config.method
|