mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-13 01:15:47 +01:00
fix call of expandObjBy with undefined
This commit is contained in:
@@ -8,10 +8,8 @@ function expandObjBy(obj1, obj2) {
|
|||||||
if (!obj1.hasOwnProperty(key) || typeof val2 !== typeof val1) {
|
if (!obj1.hasOwnProperty(key) || typeof val2 !== typeof val1) {
|
||||||
obj1[key] = val2;
|
obj1[key] = val2;
|
||||||
changed = true;
|
changed = true;
|
||||||
} else if (typeof val2 === 'object') {
|
} else if (typeof val2 === 'object' && expandObjBy(val1, val2)) {
|
||||||
if (expandObjBy(val1, val2)) {
|
changed = true;
|
||||||
changed = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return changed;
|
return changed;
|
||||||
@@ -30,7 +28,10 @@ function trim(obj1, obj2) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function mergeSettings(cfg, defCfg) {
|
function mergeSettings(cfg, defCfg) {
|
||||||
if (typeof cfg._ !== typeof defCfg || typeof defCfg !== 'object') {
|
if (typeof defCfg !== 'object') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (typeof cfg._ !== 'object') {
|
||||||
cfg._ = defCfg;
|
cfg._ = defCfg;
|
||||||
} else {
|
} else {
|
||||||
expandObjBy(cfg._, defCfg);
|
expandObjBy(cfg._, defCfg);
|
||||||
@@ -80,7 +81,10 @@ Settings.prototype.sync = function (callback) {
|
|||||||
}
|
}
|
||||||
} catch (_error) {}
|
} catch (_error) {}
|
||||||
_this.cfg = settings;
|
_this.cfg = settings;
|
||||||
if (expandObjBy(_this.cfg._, _this.defCfg)) {
|
if (typeof _this.cfg._ !== 'object') {
|
||||||
|
_this.cfg._ = _this.defCfg;
|
||||||
|
_this.persist(callback);
|
||||||
|
} else if (expandObjBy(_this.cfg._, _this.defCfg)) {
|
||||||
_this.persist(callback);
|
_this.persist(callback);
|
||||||
} else if (typeof callback === 'function') {
|
} else if (typeof callback === 'function') {
|
||||||
callback.apply(_this, err);
|
callback.apply(_this, err);
|
||||||
|
|||||||
Reference in New Issue
Block a user