diff --git a/packages/node_modules/@node-red/nodes/core/function/10-switch.js b/packages/node_modules/@node-red/nodes/core/function/10-switch.js index aa1972221..fdc345f47 100644 --- a/packages/node_modules/@node-red/nodes/core/function/10-switch.js +++ b/packages/node_modules/@node-red/nodes/core/function/10-switch.js @@ -55,6 +55,7 @@ module.exports = function(RED) { catch(e) { return false;} } else if (b === "null") { return a === null; } + else if (b === "number") { return typeof a === b && !isNaN(a) } else { return typeof a === b && !Array.isArray(a) && !Buffer.isBuffer(a) && a !== null; } }, 'head': function(a, b, c, d, parts) { diff --git a/test/nodes/core/function/10-switch_spec.js b/test/nodes/core/function/10-switch_spec.js index 180ec9d36..07896a9a4 100644 --- a/test/nodes/core/function/10-switch_spec.js +++ b/test/nodes/core/function/10-switch_spec.js @@ -310,6 +310,12 @@ describe('switch Node', function() { it('should check if payload if of type number 0', function(done) { genericSwitchTest("istype", "number", true, true, 0, done); }); + it('should check if payload if of type number NaN', function(done) { + genericSwitchTest("istype", "number", true, false, parseInt("banana"), done); + }); + it('should check if payload if of type number Infinity', function(done) { + genericSwitchTest("istype", "number", true, true, 1/0, done); + }); it('should check if payload if of type boolean true', function(done) { genericSwitchTest("istype", "boolean", true, true, true, done); });