Skip to content

Commit 634b62e

Browse files
coderabbit ai review suggestion
1 parent 6440f8c commit 634b62e

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/utils/Regex.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,12 @@ export function handleRegexMatch(
2020
const matchString = match[0]
2121

2222
let keyIndex = 1
23-
let nextIntlFunctionName = undefined
24-
if (scopes.some(s => isNextIntlScopeRange(s))) {
23+
let nextIntlFunctionName: string | undefined
24+
const hasNextIntlScope = scopes.some(s => isNextIntlScopeRange(s))
25+
// Switch to NextIntl capture layout when the regex actually provided both groups
26+
if (hasNextIntlScope && typeof match[2] !== 'undefined') {
2527
keyIndex = 2
26-
nextIntlFunctionName = match[1]
28+
nextIntlFunctionName = match[1] as string
2729
}
2830
let key = match[keyIndex]
2931
if (!key)

0 commit comments

Comments
 (0)