From a6a4620374691ae03de0ec2d79d6b027bc788cf6 Mon Sep 17 00:00:00 2001 From: HirokiUchikawa Date: Fri, 20 Jul 2018 17:03:23 +0900 Subject: [PATCH] Fix an error that occurs when evaluating `null` on `isEmpty` rule. --- nodes/core/logic/10-switch.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nodes/core/logic/10-switch.js b/nodes/core/logic/10-switch.js index e7f5cc841..89593047e 100644 --- a/nodes/core/logic/10-switch.js +++ b/nodes/core/logic/10-switch.js @@ -34,7 +34,7 @@ module.exports = function(RED) { 'empty': function(a) { if (typeof a === 'string' || Array.isArray(a) || Buffer.isBuffer(a)) { return a.length === 0; - } else if (typeof a === 'object') { + } else if (typeof a === 'object' && a !== null) { return Object.keys(a).length === 0; } return false; @@ -42,7 +42,7 @@ module.exports = function(RED) { 'nempty': function(a) { if (typeof a === 'string' || Array.isArray(a) || Buffer.isBuffer(a)) { return a.length !== 0; - } else if (typeof a === 'object') { + } else if (typeof a === 'object' && a !== null) { return Object.keys(a).length !== 0; } return false;