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

undo regression in tcp-in node (missed one)

and add test
This commit is contained in:
Dave Conway-Jones 2022-02-25 16:06:44 +00:00
parent 25f4fbf2bb
commit 0398ef3b90
No known key found for this signature in database
GPG Key ID: 88BA2B8A411BE9FF
2 changed files with 7 additions and 1 deletions

View File

@ -135,7 +135,7 @@ module.exports = function(RED) {
buffer = buffer+data;
var parts = buffer.split(node.newline);
for (var i = 0; i<parts.length-1; i+=1) {
msg = {topic:node.topic, payload:parts[i] + node.newline.trimEnd()};
msg = {topic:node.topic, payload:parts[i]};
msg._session = {type:"tcp",id:id};
node.send(msg);
}

View File

@ -121,6 +121,12 @@ describe('TCP in Node', function() {
testTCP0(flow, ["foo\nbar"], ["foo", "bar"], done);
});
it('should recv data (Stream/String/Delimiter:o\\n)', function(done) {
var flow = [{id:"n1", type:"tcp in", server:"server", host:"localhost", port:port, datamode:"stream", datatype:"utf8", newline:"o\n", topic:"", base64:false, wires:[["n2"]] },
{id:"n2", type:"helper"}];
testTCP0(flow, ["foo\nbar"], ["fo", "bar"], done);
});
it('should recv data (Stream/String/No delimiter)', function(done) {
var flow = [{id:"n1", type:"tcp in", server:"server", host:"localhost", port:port, datamode:"stream", datatype:"utf8", newline:"", topic:"", base64:false, wires:[["n2"]] },
{id:"n2", type:"helper"}];