Fix for non-object-literals in deepKeyIntersect
This commit is contained in:
parent
e4f1a6eb15
commit
a1aa995a7a
2 changed files with 13 additions and 2 deletions
|
@ -86,7 +86,10 @@ export class ZeppelinPlugin<TConfig extends {} = IBasePluginConfig> extends Plug
|
||||||
if (decodedOverrideConfig instanceof StrictValidationError) {
|
if (decodedOverrideConfig instanceof StrictValidationError) {
|
||||||
throw decodedOverrideConfig;
|
throw decodedOverrideConfig;
|
||||||
}
|
}
|
||||||
decodedOverrides.push({ ...override, config: deepKeyIntersect(decodedOverrideConfig, override.config || {}) });
|
decodedOverrides.push({
|
||||||
|
...override,
|
||||||
|
config: deepKeyIntersect(decodedOverrideConfig, override.config || {}),
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
10
src/utils.ts
10
src/utils.ts
|
@ -574,11 +574,19 @@ export class UnknownUser {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function isObjectLiteral(obj) {
|
||||||
|
let deepestPrototype = obj;
|
||||||
|
while (Object.getPrototypeOf(deepestPrototype) != null) {
|
||||||
|
deepestPrototype = Object.getPrototypeOf(deepestPrototype);
|
||||||
|
}
|
||||||
|
return Object.getPrototypeOf(obj) === deepestPrototype;
|
||||||
|
}
|
||||||
|
|
||||||
export function deepKeyIntersect(obj, keyReference) {
|
export function deepKeyIntersect(obj, keyReference) {
|
||||||
const result = {};
|
const result = {};
|
||||||
for (const [key, value] of Object.entries(obj)) {
|
for (const [key, value] of Object.entries(obj)) {
|
||||||
if (!keyReference.hasOwnProperty(key)) continue;
|
if (!keyReference.hasOwnProperty(key)) continue;
|
||||||
if (value != null && typeof value === "object" && typeof keyReference[key] === "object") {
|
if (value != null && typeof value === "object" && typeof keyReference[key] === "object" && isObjectLiteral(value)) {
|
||||||
result[key] = deepKeyIntersect(value, keyReference[key]);
|
result[key] = deepKeyIntersect(value, keyReference[key]);
|
||||||
} else {
|
} else {
|
||||||
result[key] = value;
|
result[key] = value;
|
||||||
|
|
Loading…
Add table
Reference in a new issue