Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.
fix(shared): normalize a bare Windows drive root the same as C:\ / C:/ (#6189)
Arham Amin6befe42eb096
diff --git a/packages/shared/src/path.test.ts b/packages/shared/src/path.test.tsindex 52a07aae7..799f225fb 100644--- a/packages/shared/src/path.test.ts+++ b/packages/shared/src/path.test.ts@@ -4,6 +4,8 @@ import {isUncPath,isWindowsAbsolutePath,isWindowsDrivePath,+ normalizeProjectPathForComparison,+ normalizeProjectPathForDispatch,} from "./path.ts";describe("path helpers", () => {@@ -31,4 +33,14 @@ describe("path helpers", () => {expect(isExplicitRelativePath("..\\repo")).toBe(true);expect(isExplicitRelativePath("~/repo")).toBe(false);});++ it("normalizes a bare Windows drive root the same as one with a trailing separator", () => {+ // `C:`, `C:\` and `C:/` all refer to the drive root and must compare equal.+ expect(normalizeProjectPathForDispatch("C:")).toBe("C:\\");+ expect(normalizeProjectPathForComparison("C:")).toBe("c:\\");+ expect(normalizeProjectPathForComparison("C:")).toBe(normalizeProjectPathForComparison("C:\\"));+ expect(normalizeProjectPathForComparison("C:")).toBe(normalizeProjectPathForComparison("C:/"));+ // Non-root drive paths keep their trailing separator trimmed as before.+ expect(normalizeProjectPathForDispatch("C:\\repo\\")).toBe("C:\\repo");+ });});diff --git a/packages/shared/src/path.ts b/packages/shared/src/path.tsindex 66887d3f2..b6758d814 100644--- a/packages/shared/src/path.ts+++ b/packages/shared/src/path.ts@@ -22,7 +22,11 @@ export function isExplicitRelativePath(value: string): boolean {}function isRootPath(value: string): boolean {- return value === "/" || value === "\\" || /^[a-zA-Z]:[/\\]?$/.test(value);+ // The drive separator is required: a bare `C:` is not the drive root (it+ // means "current directory on C:"), and treating it as already-canonical+ // would leave it as `C:` while `C:\` and `C:/` normalize to the drive root,+ // so the same location would fail project identity/dedup comparisons.+ return value === "/" || value === "\\" || /^[a-zA-Z]:[/\\]$/.test(value);}function trimTrailingPathSeparators(value: string): string {