Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions apps/web/src/components/files/filePath.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,19 @@ describe("fileBreadcrumbs", () => {
]);
});

it("builds home-relative breadcrumbs with navigable child folders", () => {
it("builds home-relative breadcrumbs with navigable folders", () => {
expect(fileBreadcrumbs("t3code", "~/.claude/CLAUDE.md")).toEqual([
{ label: "~", path: "~", kind: "directory" },
{ label: "~", path: "~/", kind: "directory" },
{ label: ".claude", path: "~/.claude", kind: "directory" },
{ label: "CLAUDE.md", path: "~/.claude/CLAUDE.md", kind: "file" },
]);
expect(isListableHostFolder("~/")).toBe(true);
expect(isListableHostFolder("~/.claude")).toBe(true);
});

it("keeps a project folder named ~ inside the project", () => {
expect(fileBreadcrumbs("t3code", "~").map((crumb) => crumb.path)).toEqual(["", "~"]);
});
});

describe("breadcrumbPathOf", () => {
Expand All @@ -69,6 +74,7 @@ describe("breadcrumbPathOf", () => {
["C:\\Users\\me\\", "C:\\Users\\me"],
["C:\\", "C:\\"],
["\\\\server\\share\\", "\\\\server\\share"],
["~/", "~/"],
])("writes %j as its crumb names it", (path, expected) => {
expect(breadcrumbPathOf(path)).toBe(expected);
});
Expand Down
3 changes: 2 additions & 1 deletion apps/web/src/components/files/filePath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ export function fileBreadcrumbs(projectName: string, relativePath: string): File
return {
label: part,
// A bare drive (`C:`) means the drive's current directory; its root is `C:\`.
path: /^[A-Za-z]:$/.test(path) ? `${path}\\` : path,
// A bare `~` is not a host path; the home folder is `~/`.
path: /^[A-Za-z]:$/.test(path) ? `${path}\\` : hostPath && path === "~" ? "~/" : path,
kind: index === parts.length - 1 ? ("file" as const) : ("directory" as const),
};
}),
Expand Down
Loading