Fixed potential bug in publishing from ChannelDefinition

This commit is contained in:
Jim Cowart 2013-01-11 16:25:34 -05:00
parent c0b1d21a2b
commit fea0ddf952
2 changed files with 6 additions and 2 deletions

View file

@ -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 );
};

View file

@ -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 );
};