Skip to content

Commit

Permalink
fix(Commands): Fix for images being seen as commands
Browse files Browse the repository at this point in the history
Commands must now begin with a letter, number, or underscore, though they may contain any character

after that.

Breaking Change: May invalidate previously working commands.
  • Loading branch information
yamikuronue committed Dec 8, 2016
1 parent da730a6 commit c9b6d25
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ exports.bindCommands = function bindCommands(forum) {
args.shift();
commandText = args.shift();
mention = true;
} else if (/^!\S{3,}(\s|$)/.test(line)) {
} else if (/^!\w\S{2,}(\s|$)/.test(line)) {
args = line.split(/\s+/);
commandText = args.shift().substring(1);
mention = false;
Expand Down
3 changes: 3 additions & 0 deletions test/lib/commandsTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ describe('lib/config', () => {
it('should not match really short command', () => {
expect(parseLine('!c text stuff')).to.equal(null);
});
it('should not match non-letters after !', () => {
expect(parseLine('![0_1481227127790_upload.png]')).to.equal(null);
});
it('should match bare command', () => {
parseLine('!help').command.should.equal('help');
});
Expand Down

0 comments on commit c9b6d25

Please sign in to comment.