diff --git a/src/node-to-fsa/__tests__/NodeFileSystemDirectoryHandle.test.ts b/src/node-to-fsa/__tests__/NodeFileSystemDirectoryHandle.test.ts index d70c2de61..5f392d326 100644 --- a/src/node-to-fsa/__tests__/NodeFileSystemDirectoryHandle.test.ts +++ b/src/node-to-fsa/__tests__/NodeFileSystemDirectoryHandle.test.ts @@ -303,6 +303,12 @@ onlyOnNode20('NodeFileSystemDirectoryHandle', () => { }); } + test('accepts file names beginning with a .', async () => { + const { dir } = setup({ '.hidden': 'contents' }); + const fileHandle = await dir.getFileHandle('.hidden'); + expect(fileHandle).toBeInstanceOf(NodeFileSystemFileHandle); + }); + test('can retrieve a child file', async () => { const { dir } = setup({ file: 'contents', subdir: null }); const subdir = await dir.getFileHandle('file'); diff --git a/src/node-to-fsa/util.ts b/src/node-to-fsa/util.ts index 429b8fde2..623d53f9a 100644 --- a/src/node-to-fsa/util.ts +++ b/src/node-to-fsa/util.ts @@ -18,7 +18,7 @@ export const basename = (path: string, separator: string) => { return lastSlashIndex === -1 ? path : path.slice(lastSlashIndex + 1); }; -const nameRegex = /^(\.{1,2})|(.*(\/|\\).*)$/; +const nameRegex = /^(\.{1,2})$|^(.*([\/\\]).*)$/; export const assertName = (name: string, method: string, klass: string) => { const isInvalid = !name || nameRegex.test(name);