Skip to content

Commit

Permalink
fix(filepath): allow suffix includes - and _ (honojs#2910)
Browse files Browse the repository at this point in the history
  • Loading branch information
yusukebe authored Jun 6, 2024
1 parent 817626f commit cb55866
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/utils/filepath.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ describe('getFilePath', () => {
expect(getFilePath({ filename: 'foo', root: 'bar', defaultDocument: 'index.txt' })).toBe(
'bar/foo/index.txt'
)

expect(getFilePath({ filename: 'filename.suffix_index' })).toBe('filename.suffix_index')
expect(getFilePath({ filename: 'filename.suffix-index' })).toBe('filename.suffix-index')
})
})

Expand Down
2 changes: 1 addition & 1 deletion src/utils/filepath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const getFilePath = (options: FilePathOptions): string | undefined => {
if (filename.endsWith('/')) {
// /top/ => /top/index.html
filename = filename.concat(defaultDocument)
} else if (!filename.match(/\.[a-zA-Z0-9]+$/)) {
} else if (!filename.match(/\.[a-zA-Z0-9_-]+$/)) {
// /top => /top/index.html
filename = filename.concat('/' + defaultDocument)
}
Expand Down

0 comments on commit cb55866

Please sign in to comment.