fix(fs): handle '.' path normalization on Windows (#26634)

## Summary
- Fix path normalization for "." on Windows where `normalizeStringBuf`
was incorrectly stripping it to an empty string
- This caused `existsSync('.')`, `statSync('.')`, and other fs
operations to fail on Windows

## Test plan
- Added regression test `test/regression/issue/26631.test.ts` that tests
`existsSync`, `exists`, `statSync`, and `stat` for both `.` and `..`
paths
- All tests pass locally with `bun bd test
test/regression/issue/26631.test.ts`
- Verified code compiles on all platforms with `bun run zig:check-all`

Fixes #26631

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Bot <claude-bot@bun.sh>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
robobun
2026-02-01 00:33:59 -08:00
committed by GitHub
parent 35f8154319
commit ddefa11070
2 changed files with 46 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
import { expect, test } from "bun:test";
import { existsSync, statSync } from "node:fs";
import { exists, stat } from "node:fs/promises";
// https://github.com/oven-sh/bun/issues/26631
// Path resolution fails for current directory '.' on Windows
test("existsSync('.') should return true", () => {
expect(existsSync(".")).toBe(true);
});
test("exists('.') should return true", async () => {
expect(await exists(".")).toBe(true);
});
test("statSync('.') should return directory stats", () => {
const stats = statSync(".");
expect(stats.isDirectory()).toBe(true);
});
test("stat('.') should return directory stats", async () => {
const stats = await stat(".");
expect(stats.isDirectory()).toBe(true);
});
test("existsSync('..') should return true", () => {
expect(existsSync("..")).toBe(true);
});
test("exists('..') should return true", async () => {
expect(await exists("..")).toBe(true);
});
test("statSync('..') should return directory stats", () => {
const stats = statSync("..");
expect(stats.isDirectory()).toBe(true);
});
test("stat('..') should return directory stats", async () => {
const stats = await stat("..");
expect(stats.isDirectory()).toBe(true);
});