Skip to content

Commit 50e7047

Browse files
refactor: improve regex capturing
1 parent 32c9628 commit 50e7047

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/module.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,12 @@ export default defineNuxtModule<ModuleOptions>({
4646

4747
functionBody.push(` if(to.name === ${JSON.stringify(page.name)}) {`)
4848

49-
// open to suggestion to fix this one
50-
// eslint-disable-next-line regexp/no-super-linear-backtracking
51-
for (const match of page.file.matchAll(/\[(?<pv>\S+?=\S+?)\]/g)) {
49+
for (const match of page.file.matchAll(/\[(?<param>[^\s=]+)=(?<validator>\S+?)\]/g)) {
5250
if (!match.groups) {
5351
continue
5452
}
5553

56-
const [param, validator] = match.groups.pv.split('=')
54+
const { param, validator } = match.groups
5755

5856
page.path = page.path.replace(`:${param}${validator}`, `:${param}`)
5957

0 commit comments

Comments
 (0)