From cb55866ab8ca633ffb0ca00cb863e8aee951f7ae Mon Sep 17 00:00:00 2001 From: Yusuke Wada Date: Thu, 6 Jun 2024 18:50:18 +0900 Subject: [PATCH] fix(filepath): allow suffix includes `-` and `_` (#2910) --- src/utils/filepath.test.ts | 3 +++ src/utils/filepath.ts | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) 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) }