Skip to content

Commit

Permalink
Fix input handler when input contains a colon (#269)
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Sachs committed Apr 12, 2021
1 parent 7710c21 commit 330cf92
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/flow-control/input-handler.js
Expand Up @@ -18,7 +18,7 @@ module.exports = class InputHandler {
Rx.fromEvent(this.inputStream, 'data')
.pipe(map(data => data.toString()))
.subscribe(data => {
let [targetId, input] = data.split(':', 2);
let [targetId, input] = data.split(/:(.+)/);
targetId = input ? targetId : this.defaultInputTarget;
input = input || data;

Expand Down
12 changes: 12 additions & 0 deletions src/flow-control/input-handler.spec.js
Expand Up @@ -48,6 +48,18 @@ it('forwards input stream to target index specified in input', () => {
expect(commands[1].stdin.write).toHaveBeenCalledWith('something');
});

it('forwards input stream to target index specified in input when input contains colon', () => {
controller.handle(commands);

inputStream.emit('data', Buffer.from('1::something'));
inputStream.emit('data', Buffer.from('1:some:thing'));

expect(commands[0].stdin.write).not.toHaveBeenCalled();
expect(commands[1].stdin.write).toHaveBeenCalledTimes(2);
expect(commands[1].stdin.write).toHaveBeenCalledWith(':something');
expect(commands[1].stdin.write).toHaveBeenCalledWith('some:thing');
});

it('forwards input stream to target name specified in input', () => {
controller.handle(commands);

Expand Down

0 comments on commit 330cf92

Please sign in to comment.