mirror of
https://github.com/tenrok/axios.git
synced 2026-06-20 20:00:40 +03:00
fix(core): fixed config merging bug (#6668)
Co-authored-by: rana-aakash <aakash.rana@rooter.io> Co-authored-by: Dmitriy Mozgovoy <robotshara@gmail.com>
This commit is contained in:
@@ -19,7 +19,7 @@ export default function mergeConfig(config1, config2) {
|
|||||||
config2 = config2 || {};
|
config2 = config2 || {};
|
||||||
const config = {};
|
const config = {};
|
||||||
|
|
||||||
function getMergedValue(target, source, caseless) {
|
function getMergedValue(target, source, prop, caseless) {
|
||||||
if (utils.isPlainObject(target) && utils.isPlainObject(source)) {
|
if (utils.isPlainObject(target) && utils.isPlainObject(source)) {
|
||||||
return utils.merge.call({caseless}, target, source);
|
return utils.merge.call({caseless}, target, source);
|
||||||
} else if (utils.isPlainObject(source)) {
|
} else if (utils.isPlainObject(source)) {
|
||||||
@@ -31,11 +31,11 @@ export default function mergeConfig(config1, config2) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line consistent-return
|
// eslint-disable-next-line consistent-return
|
||||||
function mergeDeepProperties(a, b, caseless) {
|
function mergeDeepProperties(a, b, prop , caseless) {
|
||||||
if (!utils.isUndefined(b)) {
|
if (!utils.isUndefined(b)) {
|
||||||
return getMergedValue(a, b, caseless);
|
return getMergedValue(a, b, prop , caseless);
|
||||||
} else if (!utils.isUndefined(a)) {
|
} else if (!utils.isUndefined(a)) {
|
||||||
return getMergedValue(undefined, a, caseless);
|
return getMergedValue(undefined, a, prop , caseless);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,7 +93,7 @@ export default function mergeConfig(config1, config2) {
|
|||||||
socketPath: defaultToConfig2,
|
socketPath: defaultToConfig2,
|
||||||
responseEncoding: defaultToConfig2,
|
responseEncoding: defaultToConfig2,
|
||||||
validateStatus: mergeDirectKeys,
|
validateStatus: mergeDirectKeys,
|
||||||
headers: (a, b) => mergeDeepProperties(headersToObject(a), headersToObject(b), true)
|
headers: (a, b , prop) => mergeDeepProperties(headersToObject(a), headersToObject(b),prop, true)
|
||||||
};
|
};
|
||||||
|
|
||||||
utils.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
|
utils.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
|
||||||
|
|||||||
Reference in New Issue
Block a user