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

Publish null/undefined to mqtt as blank not toString

Fixes #1521
This commit is contained in:
Nick O'Leary 2018-01-13 22:53:58 +00:00
parent 8ffabf1813
commit 548f45cd56
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9

View File

@ -291,7 +291,9 @@ module.exports = function(RED) {
this.publish = function (msg) { this.publish = function (msg) {
if (node.connected) { if (node.connected) {
if (!Buffer.isBuffer(msg.payload)) { if (msg.payload === null || msg.payload === undefined) {
msg.payload = "";
} else if (!Buffer.isBuffer(msg.payload)) {
if (typeof msg.payload === "object") { if (typeof msg.payload === "object") {
msg.payload = JSON.stringify(msg.payload); msg.payload = JSON.stringify(msg.payload);
} else if (typeof msg.payload !== "string") { } else if (typeof msg.payload !== "string") {