From 468ef7ecff750905091cb0e74e1b2d2cb96ee107 Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Tue, 25 May 2021 21:02:14 +0100 Subject: [PATCH] Allow RED.settings.set to replace string property with object property --- .../node_modules/@node-red/runtime/lib/api/settings.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/node_modules/@node-red/runtime/lib/api/settings.js b/packages/node_modules/@node-red/runtime/lib/api/settings.js index e8ea36f04..0224c0ca6 100644 --- a/packages/node_modules/@node-red/runtime/lib/api/settings.js +++ b/packages/node_modules/@node-red/runtime/lib/api/settings.js @@ -36,7 +36,15 @@ function extend(target, source) { } else { // Object if (target.hasOwnProperty(keys[i])) { - target[keys[i]] = extend(target[keys[i]],value); + // Target property exists. Need to handle the case + // where the existing property is a string/number/boolean + // and is being replaced wholesale. + var targetType = typeof target[keys[i]]; + if (targetType === 'string' || targetType === 'number' || targetType === 'boolean') { + target[keys[i]] = value; + } else { + target[keys[i]] = extend(target[keys[i]],value); + } } else { target[keys[i]] = value; }