Skip to content

Comments

Refactor mergeConfig without utils.deepMerge (#2844)#3

Open
MitchLewis930 wants to merge 1 commit intopr_023_beforefrom
pr_023_after
Open

Refactor mergeConfig without utils.deepMerge (#2844)#3
MitchLewis930 wants to merge 1 commit intopr_023_beforefrom
pr_023_after

Conversation

@MitchLewis930
Copy link

PR_023

* Adding failing test

* Fixing axios#2587 default custom config persisting

* Adding Concat keys and filter duplicates

* Fixed value from CPE

* update for review feedbacks

* no deepMerge

* only merge between plain objects

* fix rename

* always merge config by mergeConfig

* extract function mergeDeepProperties

* refactor mergeConfig with all keys, and add special logic for validateStatus

* add test for resetting headers

* add lots of tests and fix a bug

* should not inherit `data`

* use simple toString

* revert axios#1845

Co-authored-by: David Tanner <david.tanner@lifeomic.com>
Co-authored-by: Justin Beckwith <justin.beckwith@gmail.com>
@MitchLewis930 MitchLewis930 requested a review from Copilot January 31, 2026 00:52
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the mergeConfig function to eliminate the use of utils.deepMerge, consolidating merge functionality into a single utils.merge implementation with improved handling of plain objects, arrays, and null/undefined values.

Changes:

  • Removed utils.deepMerge function and updated utils.merge to handle deep merging with proper cloning
  • Added utils.isPlainObject to distinguish plain objects from arrays and other object types
  • Refactored mergeConfig to use a new getMergedValue helper function with distinct merge strategies for different config key types
  • Added new directMergeKeys category for properties like validateStatus that should merge even when explicitly set to undefined

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
lib/utils.js Removed deepMerge function, added isPlainObject helper, updated merge to properly clone nested objects and arrays
lib/core/mergeConfig.js Refactored to use new merge strategy with getMergedValue helper and directMergeKeys category
lib/core/Axios.js Updated method shortcuts to use mergeConfig instead of utils.merge
lib/core/dispatchRequest.js Removed null header deletion logic (now handled in merge)
test/specs/utils/merge.spec.js Added tests for cloning behavior with nested objects, arrays, and null/undefined handling
test/specs/utils/isX.spec.js Added tests for new isPlainObject function
test/specs/utils/deepMerge.spec.js Removed obsolete test file for deleted deepMerge function
test/specs/core/mergeConfig.spec.js Added comprehensive tests for different merge strategies
test/specs/headers.spec.js Updated test to reflect new null/undefined header handling behavior
test/specs/requests.spec.js Added tests for validateStatus with null/undefined values

config[prop] = config2[prop];
} else if (typeof config1[prop] !== 'undefined') {
config[prop] = config1[prop];
utils.forEach(directMergeKeys, function merge(prop) {
Copy link

Copilot AI Jan 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The callback function is named 'merge' which shadows the outer scope's utils.merge function and could cause confusion. Consider renaming to 'directMerge' or 'mergeDirectKey' to avoid ambiguity.

Suggested change
utils.forEach(directMergeKeys, function merge(prop) {
utils.forEach(directMergeKeys, function directMerge(prop) {

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants