Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ exports.encodePayload = function (packets, supportsBinary, callback) {
}

function encodeOne(packet, doneCallback) {
exports.encodePacket(packet, !isBinary ? false : supportsBinary, true, function(message) {
exports.encodePacket(packet, !isBinary ? false : supportsBinary, false, function(message) {
doneCallback(null, setLengthHeader(message));
});
}
Expand Down Expand Up @@ -407,7 +407,7 @@ exports.decodePayload = function (data, binaryType, callback) {
}

if (msg.length) {
packet = exports.decodePacket(msg, binaryType, true);
packet = exports.decodePacket(msg, binaryType, false);

if (err.type == packet.type && err.data == packet.data) {
// parser error in individual packet - ignoring payload
Expand Down
4 changes: 2 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ exports.encodePayload = function (packets, supportsBinary, callback) {
}

function encodeOne(packet, doneCallback) {
exports.encodePacket(packet, supportsBinary, true, function(message) {
exports.encodePacket(packet, supportsBinary, false, function(message) {
doneCallback(null, setLengthHeader(message));
});
}
Expand Down Expand Up @@ -302,7 +302,7 @@ exports.decodePayload = function (data, binaryType, callback) {
}

if (msg.length) {
packet = exports.decodePacket(msg, binaryType, true);
packet = exports.decodePacket(msg, binaryType, false);

if (err.type == packet.type && err.data == packet.data) {
// parser error in individual packet - ignoring payload
Expand Down
13 changes: 6 additions & 7 deletions test/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,12 @@ module.exports = function(parser) {
});
});
});

it('should not utf8 encode when dealing with strings only', function() {
encPayload([{ type: 'message', data: '€€€' }, { type: 'message', data: 'α' }], function(data) {
expect(data).to.eql('4:4€€€2:4α');
});
});
});

describe('decoding error handling', function () {
Expand Down Expand Up @@ -255,13 +261,6 @@ module.exports = function(parser) {
});
});

it('should err on invalid utf8', function () {
decPayload('2:4\uffff', function (packet, index, total) {
var isLast = index + 1 == total;
expect(packet).to.eql(err);
expect(isLast).to.eql(true);
});
});
});
});
});
Expand Down