Skip to content

Commit

Permalink
fix: support more than one path params (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
yusukebe authored Feb 16, 2024
1 parent a3e872f commit 60a0d0b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/utils/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const filePathToPath = (filePath: string) => {
.replace(/^\/?index$/, '/') // `/index`
.replace(/\/index$/, '') // `/about/index`
.replace(/\[\.{3}.+\]/, '*')
.replace(/\[(.+)\]/, ':$1')
.replace(/\[(.+?)\]/g, ':$1')
return /^\//.test(filePath) ? filePath : '/' + filePath
}

Expand Down
1 change: 1 addition & 0 deletions test/unit/utils/file.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ describe('filePathToPath', () => {
expect(filePathToPath('/about/[name].tsx')).toBe('/about/:name')
expect(filePathToPath('/about/[...foo].tsx')).toBe('/about/*')
expect(filePathToPath('/about/[name]/address.tsx')).toBe('/about/:name/address')
expect(filePathToPath('/about/[arg1]/[arg2]')).toBe('/about/:arg1/:arg2')
})
})

Expand Down

0 comments on commit 60a0d0b

Please sign in to comment.