Skip to content

Commit f5763ac

Browse files
authored
feat: support named capture for bundleMatch option (#198)
1 parent 7b6729c commit f5763ac

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/utils.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -328,9 +328,19 @@ function getLocaleMessagePathInfo (fullPath: string, bundleMatch?: string): Pars
328328
const re = new RegExp(bundleMatch, 'ig')
329329
const match = re.exec(fullPath)
330330
debug('getLocaleMessagePathInfo: regex match', match)
331-
return {
332-
locale: (match && match[1]) ? match[1] : '',
333-
filename: (match && match[2]) ? match[2] : ''
331+
if (!match) {
332+
return { locale: '', filename: '' }
333+
} else {
334+
if (match.groups) {
335+
const locale = match.groups.locale || ''
336+
const filename = match.groups.filename || ''
337+
return { locale, filename }
338+
} else {
339+
return {
340+
locale: match[1] ? match[1] : '',
341+
filename: match[2] ? match[2] : ''
342+
}
343+
}
334344
}
335345
} else {
336346
return {

0 commit comments

Comments
 (0)