GeezerVison is showing github.com — fix(web): don't label Windows paths outside the workspace as relative… · Pipyakas/t3code@7ae21bf
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboard +16Lines changed: 16 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +import { describe, expect, it } from "vite-plus/test"; |
| 2 | + |
| 3 | +import { formatWorkspaceRelativePath } from "./filePathDisplay"; |
| 4 | + |
| 5 | +describe("formatWorkspaceRelativePath", () => { |
| 6 | + it("labels only relative paths, not Windows paths outside the workspace", () => { |
| 7 | + const workspaceRoot = "C:\\Users\\mike\\dev-stuff\\t3code"; |
| 8 | + expect( |
| 9 | + formatWorkspaceRelativePath("C:\\Users\\mike\\.claude\\settings.json:3", workspaceRoot), |
| 10 | + ).toBe("C:/Users/mike/.claude/settings.json:3"); |
| 11 | + expect(formatWorkspaceRelativePath("D:/data/report.csv", workspaceRoot)).toBe( |
| 12 | + "D:/data/report.csv", |
| 13 | + ); |
| 14 | + expect(formatWorkspaceRelativePath("src/app.ts", workspaceRoot)).toBe("t3code/src/app.ts"); |
| 15 | + }); |
| 16 | +}); |
Collapse file
Copy file name to clipboardExpand all lines: apps/web/src/filePathDisplay.ts +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -46,7 +46,7 @@ export function formatWorkspaceRelativePath( |
46 | 46 | } else if (pathForCompare.startsWith(workspaceWithSeparator)) { |
47 | 47 | const relativeSuffix = normalizedPath.slice(normalizedWorkspaceRoot.length + 1); |
48 | 48 | displayPath = `${workspaceLabel}/${relativeSuffix}`; |
49 | | - } else if (!normalizedPath.startsWith("/")) { |
| 49 | + } else if (!normalizedPath.startsWith("/") && !isWindowsAbsolutePath(normalizedPath)) { |
50 | 50 | const relativePath = stripRelativePrefixes(normalizedPath); |
51 | 51 | displayPath = pathForCompare.startsWith(workspaceLabelWithSeparator) |
52 | 52 | ? normalizedPath |
|