diff --git a/lib/parse-comment.js b/lib/parse-comment.js index 9be62539..9c24c98c 100644 --- a/lib/parse-comment.js +++ b/lib/parse-comment.js @@ -134,7 +134,7 @@ nlp.plugin(plugin); function findWho(message, action) { function findWhoSafe(match) { - message = message.replace("-", "#/#"); // workaround (https://github.com/spencermountain/compromise/issues/726) + message = message.replace(/\-/g, "#/#"); // workaround (https://github.com/spencermountain/compromise/issues/726) const whoNormalizeSettings = { whitespace: true, // remove hyphens, newlines, and force one space between words case: false, // keep only first-word, and 'entity' titlecasing @@ -156,7 +156,7 @@ function findWho(message, action) { if (matchedSet.length > 0) { matchedText = matchedSet[0].text; - matchedText = matchedText.replace("#/#", "-"); + matchedText = matchedText.replace(/#\/#/g, "-"); return matchedText; } diff --git a/test/unit/parse-comment.test.js b/test/unit/parse-comment.test.js index 9c6902c2..56397ced 100644 --- a/test/unit/parse-comment.test.js +++ b/test/unit/parse-comment.test.js @@ -62,6 +62,17 @@ describe('parseComment', () => { }) }) + test('Basic intent to add - username with multiple dashes', () => { + expect( + parseComment(`@${testBotName} please add rishi-raj-jain for doc`), + ).toEqual({ + action: 'add', + contributors: { + "rishi-raj-jain": ['doc'], + }, + }) +}) + test('Basic intent to add - with plurals', () => { expect( parseComment(`@${testBotName} please add dat2 for docs`),