2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-17 19:21:29 +03:00

chore(release): v1.4.0 (#5683)

Co-authored-by: DigitalBrainJS <DigitalBrainJS@users.noreply.github.com>
This commit is contained in:
github-actions[bot]
2023-04-28 02:04:53 +03:00
committed by GitHub
parent d627610d0c
commit 21a5ad34c4
17 changed files with 136 additions and 40 deletions
+46 -7
View File
@@ -1,4 +1,4 @@
// Axios v1.3.6 Copyright (c) 2023 Matt Zabriskie and contributors
// Axios v1.4.0 Copyright (c) 2023 Matt Zabriskie and contributors
'use strict';
const FormData$1 = require('form-data');
@@ -690,6 +690,11 @@ const toJSONObject = (obj) => {
return visit(obj, 0);
};
const isAsyncFn = kindOfTest('AsyncFunction');
const isThenable = (thing) =>
thing && (isObject(thing) || isFunction(thing)) && isFunction(thing.then) && isFunction(thing.catch);
const utils = {
isArray,
isArrayBuffer,
@@ -739,7 +744,9 @@ const utils = {
ALPHABET,
generateString,
isSpecCompliantForm,
toJSONObject
toJSONObject,
isAsyncFn,
isThenable
};
/**
@@ -1954,7 +1961,7 @@ function buildFullPath(baseURL, requestedURL) {
return requestedURL;
}
const VERSION = "1.3.6";
const VERSION = "1.4.0";
function parseProtocol(url) {
const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
@@ -2424,6 +2431,21 @@ class ZlibHeaderTransformStream extends stream__default["default"].Transform {
const ZlibHeaderTransformStream$1 = ZlibHeaderTransformStream;
const callbackify = (fn, reducer) => {
return utils.isAsyncFn(fn) ? function (...args) {
const cb = args.pop();
fn.apply(this, args).then((value) => {
try {
reducer ? cb(null, ...reducer(value)) : cb(null, value);
} catch (err) {
cb(err);
}
}, cb);
} : fn;
};
const callbackify$1 = callbackify;
const zlibOptions = {
flush: zlib__default["default"].constants.Z_SYNC_FLUSH,
finishFlush: zlib__default["default"].constants.Z_SYNC_FLUSH
@@ -2546,13 +2568,24 @@ const wrapAsync = (asyncExecutor) => {
/*eslint consistent-return:0*/
const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
return wrapAsync(async function dispatchHttpRequest(resolve, reject, onDone) {
let {data} = config;
let {data, lookup, family} = config;
const {responseType, responseEncoding} = config;
const method = config.method.toUpperCase();
let isDone;
let rejected = false;
let req;
if (lookup && utils.isAsyncFn(lookup)) {
lookup = callbackify$1(lookup, (entry) => {
if(utils.isString(entry)) {
entry = [entry, entry.indexOf('.') < 0 ? 6 : 4];
} else if (!utils.isArray(entry)) {
throw new TypeError('lookup async function must return an array [ip: string, family: number]]')
}
return entry;
});
}
// temporary internal emitter until the AxiosRequest class will be implemented
const emitter = new EventEmitter__default["default"]();
@@ -2776,6 +2809,8 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
agents: { http: config.httpAgent, https: config.httpsAgent },
auth,
protocol,
family,
lookup,
beforeRedirect: dispatchBeforeRedirect,
beforeRedirects: {}
};
@@ -3205,8 +3240,12 @@ const xhrAdapter = isXHRAdapterSupported && function (config) {
}
}
if (utils.isFormData(requestData) && (platform.isStandardBrowserEnv || platform.isStandardBrowserWebWorkerEnv)) {
requestHeaders.setContentType(false); // Let the browser set it
if (utils.isFormData(requestData)) {
if (platform.isStandardBrowserEnv || platform.isStandardBrowserWebWorkerEnv) {
requestHeaders.setContentType(false); // Let the browser set it
} else {
requestHeaders.setContentType('multipart/form-data;', false); // mobile/desktop app frameworks
}
}
let request = new XMLHttpRequest();
@@ -3612,7 +3651,7 @@ function mergeConfig(config1, config2) {
headers: (a, b) => mergeDeepProperties(headersToObject(a), headersToObject(b), true)
};
utils.forEach(Object.keys(config1).concat(Object.keys(config2)), function computeConfigValue(prop) {
utils.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
const merge = mergeMap[prop] || mergeDeepProperties;
const configValue = merge(config1[prop], config2[prop], prop);
(utils.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
+1 -1
View File
File diff suppressed because one or more lines are too long