1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Don't default inject payload to blank string

This commit is contained in:
Nick O'Leary 2016-02-04 21:43:18 +00:00
parent d3a29a6f16
commit c7bcd3f438
2 changed files with 5 additions and 7 deletions

View File

@ -1,5 +1,5 @@
/** /**
* Copyright 2013, 2015 IBM Corp. * Copyright 2013, 2016 IBM Corp.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -58,7 +58,7 @@ module.exports = function(RED) {
} else if (this.payloadType == 'none') { } else if (this.payloadType == 'none') {
msg.payload = ""; msg.payload = "";
} else { } else {
msg.payload = RED.util.evaluateNodeProperty(this.payload,this.payloadType,this,msg)||""; msg.payload = RED.util.evaluateNodeProperty(this.payload,this.payloadType,this,msg);
} }
this.send(msg); this.send(msg);
msg = null; msg = null;

View File

@ -1,5 +1,5 @@
/** /**
* Copyright 2014, 2015 IBM Corp. * Copyright 2014, 2016 IBM Corp.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -153,8 +153,7 @@ function evaluateNodeProperty(value, type, node, msg) {
if (type === 'str') { if (type === 'str') {
return ""+value; return ""+value;
} else if (type === 'num') { } else if (type === 'num') {
/*jshint -W053 */ return Number(value);
return new Number(value);
} else if (type === 'json') { } else if (type === 'json') {
return JSON.parse(value); return JSON.parse(value);
} else if (type === 're') { } else if (type === 're') {
@ -166,8 +165,7 @@ function evaluateNodeProperty(value, type, node, msg) {
} else if (type === 'global' && node) { } else if (type === 'global' && node) {
return node.context().global.get(value); return node.context().global.get(value);
} else if (type === 'bool') { } else if (type === 'bool') {
/*jshint -W053 */ return /^true$/i.test(value);
return new Boolean(/^true$/i.test(value));
} }
return value; return value;
} }