Skip to content

Commit b8905eb

Browse files
authored
fix: fix handle paths in FSA entries iterator (#1019)
* fix: fix file handle path in FSA entries iterator * Fix directory handle paths and add assertions
1 parent cf9b0b3 commit b8905eb

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/node-to-fsa/NodeFileSystemDirectoryHandle.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ export class NodeFileSystemDirectoryHandle extends NodeFileSystemHandle implemen
5757
for (const d of list) {
5858
const dirent = d as Dirent;
5959
const name = dirent.name + '';
60-
const newPath = path + ctx.separator! + name;
60+
const newPath = path + name;
6161
if (dirent.isDirectory()) yield [name, new NodeFileSystemDirectoryHandle(fs, newPath, ctx)];
62-
else if (dirent.isFile()) yield [name, new NodeFileSystemFileHandle(fs, name, ctx)];
62+
else if (dirent.isFile()) yield [name, new NodeFileSystemFileHandle(fs, newPath, ctx)];
6363
}
6464
}
6565

src/node-to-fsa/__tests__/NodeFileSystemDirectoryHandle.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ onlyOnNode20('NodeFileSystemDirectoryHandle', () => {
6464
expect(subdir).toBeInstanceOf(NodeFileSystemDirectoryHandle);
6565
expect(subdir.kind).toBe('directory');
6666
expect(subdir.name).toBe('My Documents');
67+
expect((subdir as NodeFileSystemDirectoryHandle).__path).toBe('/My Documents/');
6768
}
6869
});
6970

@@ -76,6 +77,7 @@ onlyOnNode20('NodeFileSystemDirectoryHandle', () => {
7677
expect(file).toBeInstanceOf(NodeFileSystemFileHandle);
7778
expect(file.kind).toBe('file');
7879
expect(file.name).toBe('file.txt');
80+
await expect((file as NodeFileSystemFileHandle).getFile()).resolves.toBeInstanceOf(File);
7981
}
8082
});
8183

0 commit comments

Comments
 (0)