mirror of
https://github.com/anthropics/claude-code-action.git
synced 2026-07-27 22:38:30 +08:00
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.
This commit is contained in:
parent
fefa07e9c6
commit
38f25dd747
@ -51,6 +51,7 @@ export function checkContainsTrigger(context: ParsedGitHubContext): boolean {
|
|||||||
// Check for exact match with word boundaries or punctuation
|
// Check for exact match with word boundaries or punctuation
|
||||||
const regex = new RegExp(
|
const regex = new RegExp(
|
||||||
`(^|\\s)${escapeRegExp(triggerPhrase)}([\\s.,!?;:]|$)`,
|
`(^|\\s)${escapeRegExp(triggerPhrase)}([\\s.,!?;:]|$)`,
|
||||||
|
"i",
|
||||||
);
|
);
|
||||||
|
|
||||||
// Check in body
|
// Check in body
|
||||||
@ -77,6 +78,7 @@ export function checkContainsTrigger(context: ParsedGitHubContext): boolean {
|
|||||||
// Check for exact match with word boundaries or punctuation
|
// Check for exact match with word boundaries or punctuation
|
||||||
const regex = new RegExp(
|
const regex = new RegExp(
|
||||||
`(^|\\s)${escapeRegExp(triggerPhrase)}([\\s.,!?;:]|$)`,
|
`(^|\\s)${escapeRegExp(triggerPhrase)}([\\s.,!?;:]|$)`,
|
||||||
|
"i",
|
||||||
);
|
);
|
||||||
|
|
||||||
// Check in body
|
// Check in body
|
||||||
@ -105,6 +107,7 @@ export function checkContainsTrigger(context: ParsedGitHubContext): boolean {
|
|||||||
// Check for exact match with word boundaries or punctuation
|
// Check for exact match with word boundaries or punctuation
|
||||||
const regex = new RegExp(
|
const regex = new RegExp(
|
||||||
`(^|\\s)${escapeRegExp(triggerPhrase)}([\\s.,!?;:]|$)`,
|
`(^|\\s)${escapeRegExp(triggerPhrase)}([\\s.,!?;:]|$)`,
|
||||||
|
"i",
|
||||||
);
|
);
|
||||||
if (regex.test(reviewBody)) {
|
if (regex.test(reviewBody)) {
|
||||||
console.log(
|
console.log(
|
||||||
@ -125,6 +128,7 @@ export function checkContainsTrigger(context: ParsedGitHubContext): boolean {
|
|||||||
// Check for exact match with word boundaries or punctuation
|
// Check for exact match with word boundaries or punctuation
|
||||||
const regex = new RegExp(
|
const regex = new RegExp(
|
||||||
`(^|\\s)${escapeRegExp(triggerPhrase)}([\\s.,!?;:]|$)`,
|
`(^|\\s)${escapeRegExp(triggerPhrase)}([\\s.,!?;:]|$)`,
|
||||||
|
"i",
|
||||||
);
|
);
|
||||||
if (regex.test(commentBody)) {
|
if (regex.test(commentBody)) {
|
||||||
console.log(`Comment contains exact trigger phrase '${triggerPhrase}'`);
|
console.log(`Comment contains exact trigger phrase '${triggerPhrase}'`);
|
||||||
|
|||||||
@ -186,6 +186,8 @@ describe("checkContainsTrigger", () => {
|
|||||||
{ issueBody: "@claude: here's the issue", expected: true },
|
{ issueBody: "@claude: here's the issue", expected: true },
|
||||||
{ issueBody: "@claude; and another thing", expected: true },
|
{ issueBody: "@claude; and another thing", expected: true },
|
||||||
{ issueBody: "Hey @claude, can you help?", expected: true },
|
{ issueBody: "Hey @claude, can you help?", expected: true },
|
||||||
|
{ issueBody: "@Claude can you help?", expected: true },
|
||||||
|
{ issueBody: "@CLAUDE fix this", expected: true },
|
||||||
{ issueBody: "claudette contains claude", expected: false },
|
{ issueBody: "claudette contains claude", expected: false },
|
||||||
{ issueBody: "email@claude.com", expected: false },
|
{ issueBody: "email@claude.com", expected: false },
|
||||||
];
|
];
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user