diff --git a/src/utils/filepath.test.ts b/src/utils/filepath.test.ts index 5d6482e2d..875ef8cb7 100644 --- a/src/utils/filepath.test.ts +++ b/src/utils/filepath.test.ts @@ -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') }) }) diff --git a/src/utils/filepath.ts b/src/utils/filepath.ts index 1a2c2268b..f3f2ea82e 100644 --- a/src/utils/filepath.ts +++ b/src/utils/filepath.ts @@ -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) }