Skip to content

Commit 8a84507

Browse files
brandonrobertsgr2m
authored andcommitted
fix: fix support for usernames with multiple dashes
1 parent 205ccee commit 8a84507

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

lib/parse-comment.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ nlp.plugin(plugin);
133133

134134
function findWho(message, action) {
135135
function findWhoSafe(match) {
136-
message = message.replace("-", "#/#"); // workaround (https://github.com/spencermountain/compromise/issues/726)
136+
message = message.replace(/\-/g, "#/#"); // workaround (https://github.com/spencermountain/compromise/issues/726)
137137
const whoNormalizeSettings = {
138138
whitespace: true, // remove hyphens, newlines, and force one space between words
139139
case: false, // keep only first-word, and 'entity' titlecasing
@@ -155,7 +155,7 @@ function findWho(message, action) {
155155

156156
if (matchedSet.length > 0) {
157157
matchedText = matchedSet[0].text;
158-
matchedText = matchedText.replace("#/#", "-");
158+
matchedText = matchedText.replace(/#\/#/g, "-");
159159

160160
return matchedText;
161161
}

test/unit/parse-comment.test.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,17 @@ describe('parseComment', () => {
6262
})
6363
})
6464

65+
test('Basic intent to add - username with multiple dashes', () => {
66+
expect(
67+
parseComment(`@${testBotName} please add rishi-raj-jain for doc`),
68+
).toEqual({
69+
action: 'add',
70+
contributors: {
71+
"rishi-raj-jain": ['doc'],
72+
},
73+
})
74+
})
75+
6576
test('Basic intent to add - with plurals', () => {
6677
expect(
6778
parseComment(`@${testBotName} please add dat2 for docs`),

0 commit comments

Comments
 (0)