Skip to content

Commit 38f25dd

Browse files
authored
fix: make trigger_phrase match case-insensitive (#1279)
GitHub @-mention autocomplete inserts @claude (capitalized) when users pick the bot from the dropdown, but the trigger regex had no 'i' flag, so the action would log 'No trigger was met for @claude' and exit. The workflow's outer 'if: contains(...)' gate is case-insensitive, so the job runs and looks like it silently ignored the user. The regex was case-sensitive since the initial commit with no test asserting either behavior; the existing tests focus on word-boundary precision (email@claude.com etc.), not case.
1 parent fefa07e commit 38f25dd

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

src/github/validation/trigger.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ export function checkContainsTrigger(context: ParsedGitHubContext): boolean {
5151
// Check for exact match with word boundaries or punctuation
5252
const regex = new RegExp(
5353
`(^|\\s)${escapeRegExp(triggerPhrase)}([\\s.,!?;:]|$)`,
54+
"i",
5455
);
5556

5657
// Check in body
@@ -77,6 +78,7 @@ export function checkContainsTrigger(context: ParsedGitHubContext): boolean {
7778
// Check for exact match with word boundaries or punctuation
7879
const regex = new RegExp(
7980
`(^|\\s)${escapeRegExp(triggerPhrase)}([\\s.,!?;:]|$)`,
81+
"i",
8082
);
8183

8284
// Check in body
@@ -105,6 +107,7 @@ export function checkContainsTrigger(context: ParsedGitHubContext): boolean {
105107
// Check for exact match with word boundaries or punctuation
106108
const regex = new RegExp(
107109
`(^|\\s)${escapeRegExp(triggerPhrase)}([\\s.,!?;:]|$)`,
110+
"i",
108111
);
109112
if (regex.test(reviewBody)) {
110113
console.log(
@@ -125,6 +128,7 @@ export function checkContainsTrigger(context: ParsedGitHubContext): boolean {
125128
// Check for exact match with word boundaries or punctuation
126129
const regex = new RegExp(
127130
`(^|\\s)${escapeRegExp(triggerPhrase)}([\\s.,!?;:]|$)`,
131+
"i",
128132
);
129133
if (regex.test(commentBody)) {
130134
console.log(`Comment contains exact trigger phrase '${triggerPhrase}'`);

test/trigger-validation.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,8 @@ describe("checkContainsTrigger", () => {
186186
{ issueBody: "@claude: here's the issue", expected: true },
187187
{ issueBody: "@claude; and another thing", expected: true },
188188
{ issueBody: "Hey @claude, can you help?", expected: true },
189+
{ issueBody: "@Claude can you help?", expected: true },
190+
{ issueBody: "@CLAUDE fix this", expected: true },
189191
{ issueBody: "claudette contains claude", expected: false },
190192
{ issueBody: "email@claude.com", expected: false },
191193
];

0 commit comments

Comments
 (0)