Skip to content

Commit 5394a7c

Browse files
fix: added support for uppercase in multiplier regex (#503)
* fix: added support for uppercase in multiplier regex * fix: added the 2nd part of the multiplier regex back * test: added test case for uppercase multiplier
1 parent f3f83f8 commit 5394a7c

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

service/recognition.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const tagRegex = /#(\S+)/g;
2020
const generalEmojiRegex = /:([a-z-_']+):/g;
2121
const gratitudeEmojiRegex = new RegExp(config.recognizeEmoji, "g");
2222
const multiplierRegex = new RegExp(
23-
`${config.recognizeEmoji}\\s*x([0-9]+)|x([0-9]+)\\s${config.recognizeEmoji}`,
23+
`${config.recognizeEmoji}\\s*[Xx]([0-9]+)|[Xx]([0-9]+)\\s${config.recognizeEmoji}`,
2424
);
2525

2626
// TODO Can we add a 'count' field to the recognition?

test/service/recognition.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,20 @@ describe("service/recognition", () => {
472472
const result = recognition.gratitudeCountIn(text);
473473
expect(result).to.equal(5);
474474
});
475+
476+
it("should count uppercase multiplier", async () => {
477+
const text =
478+
"uppercase multiplier X5 :fistbump: <@TestUser> Test Message";
479+
const result = recognition.gratitudeCountIn(text);
480+
expect(result).to.equal(5);
481+
});
482+
483+
it("shouldn't use an uppercase multiplier that's not 'X'", async () => {
484+
const text =
485+
"uppercase fake multiplier Y5 :fistbump: <@TestUser> Test Message";
486+
const result = recognition.gratitudeCountIn(text);
487+
expect(result).to.equal(1);
488+
});
475489
});
476490

477491
describe("gratitudeTagsIn", () => {

0 commit comments

Comments
 (0)