From fea0ddf952907f3741f497f5562cd6c1dd931b69 Mon Sep 17 00:00:00 2001 From: Jim Cowart Date: Fri, 11 Jan 2013 16:25:34 -0500 Subject: [PATCH] Fixed potential bug in publishing from ChannelDefinition --- lib/postal.js | 4 +++- src/ChannelDefinition.js | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/postal.js b/lib/postal.js index 4cbcbbf..5091e43 100644 --- a/lib/postal.js +++ b/lib/postal.js @@ -67,7 +67,9 @@ }; ChannelDefinition.prototype.publish = function () { - var envelope = arguments.length === 1 ? arguments[0] : { topic : arguments[0], data : arguments[1] }; + var envelope = arguments.length === 1 ? + (Object.prototype.toString.call(arguments[0]) === '[object String]' ? + arguments[0] : { topic: arguments[0] }) : { topic : arguments[0], data : arguments[1] }; envelope.channel = this.channel; return postal.configuration.bus.publish( envelope ); }; diff --git a/src/ChannelDefinition.js b/src/ChannelDefinition.js index e1e5768..6f49c16 100644 --- a/src/ChannelDefinition.js +++ b/src/ChannelDefinition.js @@ -9,7 +9,9 @@ ChannelDefinition.prototype.subscribe = function () { }; ChannelDefinition.prototype.publish = function () { - var envelope = arguments.length === 1 ? arguments[0] : { topic : arguments[0], data : arguments[1] }; + var envelope = arguments.length === 1 ? + (Object.prototype.toString.call(arguments[0]) === '[object String]' ? + arguments[0] : { topic: arguments[0] }) : { topic : arguments[0], data : arguments[1] }; envelope.channel = this.channel; return postal.configuration.bus.publish( envelope ); }; \ No newline at end of file