Skip to content

Commit ec5c744

Browse files
committed
fix: config merge bug where false defaults became {} on object override
1 parent 6f21408 commit ec5c744

1 file changed

Lines changed: 12 additions & 13 deletions

File tree

.vitepress/utils.js

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,20 @@ import { dirname, join } from 'path'
44

55
// Deep merge function to handle nested objects
66
export function deepMerge(target, source) {
7+
if (!isObject(target) || !isObject(source)) {
8+
return source
9+
}
10+
711
const output = { ...target }
812

9-
if (isObject(target) && isObject(source)) {
10-
Object.keys(source).forEach(key => {
11-
if (isObject(source[key])) {
12-
if (!(key in target)) {
13-
output[key] = source[key]
14-
} else {
15-
output[key] = deepMerge(target[key], source[key])
16-
}
17-
} else {
18-
output[key] = source[key]
19-
}
20-
})
21-
}
13+
Object.keys(source).forEach(key => {
14+
if (isObject(source[key]) && isObject(target[key])) {
15+
output[key] = deepMerge(target[key], source[key])
16+
return
17+
}
18+
19+
output[key] = source[key]
20+
})
2221

2322
return output
2423
}

0 commit comments

Comments
 (0)