diff --git a/__tests__/symlinks.test.ts b/__tests__/symlinks.test.ts index c4e0c7a..c0df753 100644 --- a/__tests__/symlinks.test.ts +++ b/__tests__/symlinks.test.ts @@ -341,6 +341,15 @@ for (const type of apiTypes) { t.expect(files.sort()).toStrictEqual(normalize(["/other/dir/file-2"])); }); + test("resolve symlinks (exclude /some/dir/dirSymlink/, real paths: false)", async (t) => { + const api = new fdir() + .withSymlinks({ resolvePaths: false }) + .exclude((_name, path) => path === resolveSymlinkRoot("/some/dir/dirSymlink/")) + .crawl("/some/dir") + const files = await api[type](); + t.expect(files.sort()).toStrictEqual(normalize(["/some/dir/fileSymlink"])); + }); + test(`do not resolve symlinks`, async (t) => { const api = new fdir().crawl("/some/dir"); const files = await api[type](); diff --git a/src/api/walker.ts b/src/api/walker.ts index 590cea1..09a1fc8 100644 --- a/src/api/walker.ts +++ b/src/api/walker.ts @@ -118,7 +118,7 @@ export class Walker { this.resolveSymlink(path, this.state, (stat, resolvedPath) => { if (stat.isDirectory()) { resolvedPath = normalizePath(resolvedPath, this.state.options); - if (exclude && exclude(entry.name, resolvedPath)) return; + if (exclude && exclude(entry.name, useRealPaths ? resolvedPath : path + pathSeparator)) return; this.walkDirectory( this.state,