Skip to content

Commit

Permalink
fix: ensure consistent file path formatting when reading directories …
Browse files Browse the repository at this point in the history
…recursively (#990)
  • Loading branch information
G-Rath authored Feb 13, 2024
1 parent 817f3e6 commit 36def27
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/volume.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1488,9 +1488,15 @@ export class Volume implements FsCallbackApi, FsSynchronousApi {

if (options.withFileTypes) return list;

let filename2 = filename;

if (isWin) {
filename2 = filename2.replace(/\\/g, '/');
}

return list.map(dirent => {
if (options.recursive) {
return dirent.path.replace(filename + pathModule.sep, '');
return dirent.path.replace(filename2 + pathModule.posix.sep, '');
}
return dirent.name;
});
Expand Down

0 comments on commit 36def27

Please sign in to comment.