axios 1.3.5 → 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 +38 -0
- package/dist/axios.js +20 -8
- 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 +26 -11
- package/dist/browser/axios.cjs.map +1 -1
- package/dist/esm/axios.js +26 -11
- 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 +55 -12
- package/dist/node/axios.cjs.map +1 -1
- package/index.d.cts +22 -18
- package/index.d.ts +6 -2
- package/lib/adapters/http.js +15 -1
- package/lib/adapters/xhr.js +6 -2
- 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
|
/**
|
@@ -1950,7 +1961,7 @@ function buildFullPath(baseURL, requestedURL) {
|
|
1950
1961
|
return requestedURL;
|
1951
1962
|
}
|
1952
1963
|
|
1953
|
-
const VERSION = "1.
|
1964
|
+
const VERSION = "1.4.0";
|
1954
1965
|
|
1955
1966
|
function parseProtocol(url) {
|
1956
1967
|
const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
|
@@ -2420,6 +2431,21 @@ class ZlibHeaderTransformStream extends stream__default["default"].Transform {
|
|
2420
2431
|
|
2421
2432
|
const ZlibHeaderTransformStream$1 = ZlibHeaderTransformStream;
|
2422
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
|
+
|
2423
2449
|
const zlibOptions = {
|
2424
2450
|
flush: zlib__default["default"].constants.Z_SYNC_FLUSH,
|
2425
2451
|
finishFlush: zlib__default["default"].constants.Z_SYNC_FLUSH
|
@@ -2542,13 +2568,24 @@ const wrapAsync = (asyncExecutor) => {
|
|
2542
2568
|
/*eslint consistent-return:0*/
|
2543
2569
|
const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
|
2544
2570
|
return wrapAsync(async function dispatchHttpRequest(resolve, reject, onDone) {
|
2545
|
-
let {data} = config;
|
2571
|
+
let {data, lookup, family} = config;
|
2546
2572
|
const {responseType, responseEncoding} = config;
|
2547
2573
|
const method = config.method.toUpperCase();
|
2548
2574
|
let isDone;
|
2549
2575
|
let rejected = false;
|
2550
2576
|
let req;
|
2551
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
|
+
|
2552
2589
|
// temporary internal emitter until the AxiosRequest class will be implemented
|
2553
2590
|
const emitter = new EventEmitter__default["default"]();
|
2554
2591
|
|
@@ -2772,6 +2809,8 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
|
|
2772
2809
|
agents: { http: config.httpAgent, https: config.httpsAgent },
|
2773
2810
|
auth,
|
2774
2811
|
protocol,
|
2812
|
+
family,
|
2813
|
+
lookup,
|
2775
2814
|
beforeRedirect: dispatchBeforeRedirect,
|
2776
2815
|
beforeRedirects: {}
|
2777
2816
|
};
|
@@ -3201,8 +3240,12 @@ const xhrAdapter = isXHRAdapterSupported && function (config) {
|
|
3201
3240
|
}
|
3202
3241
|
}
|
3203
3242
|
|
3204
|
-
if (utils.isFormData(requestData)
|
3205
|
-
|
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
|
+
}
|
3206
3249
|
}
|
3207
3250
|
|
3208
3251
|
let request = new XMLHttpRequest();
|
@@ -3608,7 +3651,7 @@ function mergeConfig(config1, config2) {
|
|
3608
3651
|
headers: (a, b) => mergeDeepProperties(headersToObject(a), headersToObject(b), true)
|
3609
3652
|
};
|
3610
3653
|
|
3611
|
-
utils.forEach(Object.keys(
|
3654
|
+
utils.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
|
3612
3655
|
const merge = mergeMap[prop] || mergeDeepProperties;
|
3613
3656
|
const configValue = merge(config1[prop], config2[prop], prop);
|
3614
3657
|
(utils.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
|