Compare View

switch
from
...
to
 
Commits (2)

Changes

Showing 4 changed files Side-by-side Diff

lib/command-parser.js
... ... @@ -11,7 +11,11 @@ function splitToken(msg) {
11 11 return;
12 12 }
13 13  
14   - return msg.trim().split(/[\s\.]+/); // eslint-disable-line no-useless-escape
  14 + const delimiters = msg.trim().match(/^\w+(\W)/);
  15 + const delimiter = delimiters && delimiters[1] ? delimiters[1] : null;
  16 +
  17 + const delimiterRegex = delimiter ? new RegExp('\\' + delimiter + '+') : new RegExp('[\\s\\.]+');
  18 + return msg.trim().split(delimiterRegex);
15 19 }
16 20  
17 21 function _makeSureAsTokensArray(msgOrTokens) {
1 1 {
2 2 "name": "komodo-center-messaging",
3   - "version": "0.9.8",
  3 + "version": "0.9.9",
4 4 "lockfileVersion": 1,
5 5 "requires": true,
6 6 "dependencies": {
1 1 {
2 2 "name": "komodo-center-messaging",
3   - "version": "0.9.8",
  3 + "version": "0.9.9",
4 4 "description": "Komodo Common Messaging Center",
5 5 "main": "index.js",
6 6 "scripts": {
test/command-parser.js
... ... @@ -13,6 +13,10 @@ describe('#command-parser', function() {
13 13  
14 14 commandParser.splitToken('SAL.1234')[1].should.equal('1234');
15 15 commandParser.splitToken('SAL 1234')[1].should.equal('1234');
  16 +
  17 + })
  18 +
  19 + it('should handle repeating splitter', function() {
16 20 commandParser.splitToken('SAL 1234')[1].should.equal('1234');
17 21 })
18 22