diff --git a/nodes/core/logic/17-split.html b/nodes/core/logic/17-split.html index bb03b4439..1979bd814 100644 --- a/nodes/core/logic/17-split.html +++ b/nodes/core/logic/17-split.html @@ -239,6 +239,9 @@ var val = $(this).val(); $(".node-row-custom").toggle(val==='custom'); $(".form-tips-auto").toggle(val==='auto'); + if (val === "auto") { + $("#node-input-accumulate").attr('checked', false); + } }); $("#node-input-build").change(function(e) { diff --git a/nodes/core/logic/17-split.js b/nodes/core/logic/17-split.js index ef6368454..083feaeec 100644 --- a/nodes/core/logic/17-split.js +++ b/nodes/core/logic/17-split.js @@ -354,9 +354,12 @@ module.exports = function(RED) { currentCount:0, payload:{}, targetCount:targetCount, - type:"object", + type:payloadType, msg:msg } + if (payloadType === 'string') { + inflight[partId].payload = []; + } } else { inflight[partId] = { @@ -364,7 +367,6 @@ module.exports = function(RED) { payload:[], targetCount:targetCount, type:payloadType, - joinChar: joinChar, msg:msg }; if (payloadType === 'string') { @@ -374,7 +376,6 @@ module.exports = function(RED) { } else if (payloadType === 'buffer') { inflight[partId].bufferLen = 0; } - } if (node.timer > 0) { inflight[partId].timeout = setTimeout(function() { diff --git a/test/nodes/core/logic/17-split_spec.js b/test/nodes/core/logic/17-split_spec.js index b11d59add..9a6b49d43 100644 --- a/test/nodes/core/logic/17-split_spec.js +++ b/test/nodes/core/logic/17-split_spec.js @@ -144,6 +144,27 @@ describe('JOIN node', function() { }); }); + it('should join bits of string back together automatically', function(done) { + var flow = [{id:"n1", type:"join", wires:[["n2"]], joiner:",", build:"string", mode:"auto"}, + {id:"n2", type:"helper"}]; + helper.load(joinNode, flow, function() { + var n1 = helper.getNode("n1"); + var n2 = helper.getNode("n2"); + n2.on("input", function(msg) { + try { + msg.should.have.property("payload"); + msg.payload.should.equal("A,B,C,D"); + done(); + } + catch(e) {done(e);} + }); + n1.receive({payload:"A", parts:{id:1, type:"string", ch:",", index:0, count:4}}); + n1.receive({payload:"B", parts:{id:1, type:"string", ch:",", index:1, count:4}}); + n1.receive({payload:"C", parts:{id:1, type:"string", ch:",", index:2, count:4}}); + n1.receive({payload:"D", parts:{id:1, type:"string", ch:",", index:3, count:4}}); + }); + }); + it('should join things into an array after a count', function(done) { var flow = [{id:"n1", type:"join", wires:[["n2"]], count:3, joiner:",",mode:"custom"}, {id:"n2", type:"helper"}];