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