Skip to content

Commit acb5118

Browse files
authored
feat: add support for @allcontributors (one word) (#110)
1 parent 90841af commit acb5118

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

src/utils/isMessageForBot.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
function isMessageForBot(message) {
2+
const lowerCaseMessage = message.toLowerCase()
23
const isMessageForBot =
3-
message.includes(`@all-contributors`) ||
4-
message.includes(`@allcontributors[bot]`)
4+
lowerCaseMessage.includes(`@all-contributors`) ||
5+
lowerCaseMessage.includes(`@allcontributors`) ||
6+
lowerCaseMessage.includes(`@allcontributors[bot]`)
57
return isMessageForBot
68
}
79

test/utils/isMessageForBot.test.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
const isMessageForBot = require('../../src/utils/isMessageForBot')
22

33
describe('isMessageForBot', () => {
4-
const testBotName = 'all-contributors'
5-
64
test('For us', () => {
75
expect(
86
isMessageForBot(
9-
`@${testBotName} please add jakebolam for doc, infra and code`,
7+
`@all-contributors please add jakebolam for doc, infra and code`,
108
),
119
).toBe(true)
1210

@@ -15,12 +13,26 @@ describe('isMessageForBot', () => {
1513
`@allcontributors[bot] please add jakebolam for doc, infra and code`,
1614
),
1715
).toBe(true)
16+
17+
expect(
18+
isMessageForBot(
19+
`@allcontributors please add jakebolam for doc, infra and code`,
20+
),
21+
).toBe(true)
22+
})
23+
24+
test('For us, case in-sensitive', () => {
25+
expect(
26+
isMessageForBot(
27+
`@aLL-conTRIBUtors please add jakebolam for doc, infra and code`,
28+
),
29+
).toBe(true)
1830
})
1931

2032
test('Not for us', () => {
2133
expect(
2234
isMessageForBot(
23-
`${testBotName} please add jakebolam for doc, infra and code`,
35+
`all-contributors please add jakebolam for doc, infra and code`,
2436
),
2537
).toBe(false)
2638

0 commit comments

Comments
 (0)