Skip to content

Commit

Permalink
fix(core): fixed config merging bug (axios#6668)
Browse files Browse the repository at this point in the history
Co-authored-by: rana-aakash <[email protected]>
Co-authored-by: Dmitriy Mozgovoy <[email protected]>
  • Loading branch information
3 people authored Oct 30, 2024
1 parent 76dc3e6 commit 5d99fe4
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/core/mergeConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default function mergeConfig(config1, config2) {
config2 = config2 || {};
const config = {};

function getMergedValue(target, source, caseless) {
function getMergedValue(target, source, prop, caseless) {
if (utils.isPlainObject(target) && utils.isPlainObject(source)) {
return utils.merge.call({caseless}, target, source);
} else if (utils.isPlainObject(source)) {
Expand All @@ -31,11 +31,11 @@ export default function mergeConfig(config1, config2) {
}

// eslint-disable-next-line consistent-return
function mergeDeepProperties(a, b, caseless) {
function mergeDeepProperties(a, b, prop , caseless) {
if (!utils.isUndefined(b)) {
return getMergedValue(a, b, caseless);
return getMergedValue(a, b, prop , caseless);
} else if (!utils.isUndefined(a)) {
return getMergedValue(undefined, a, caseless);
return getMergedValue(undefined, a, prop , caseless);
}
}

Expand Down Expand Up @@ -93,7 +93,7 @@ export default function mergeConfig(config1, config2) {
socketPath: defaultToConfig2,
responseEncoding: defaultToConfig2,
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) {
Expand Down

0 comments on commit 5d99fe4

Please sign in to comment.