The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 22, 07:00 UTC
fix(shared): Linux file links preserve literal backslashes (#29245)
Lakshmi Tanmay committed
Nov 3, 2026 at 07:10 UTC
efcb93769599f7d32b12174f58009bb7cc6c665a
2 files changed
+25
-4
packages/shared/src/path.test.ts
+15
@@ -106,6 +106,21 @@ describe("workspaceRelativeFilePath", () => {
106
["/repo/project/../other/notes.md", "/repo/project", null],
107
["C:\\repo\\project\\src\\..\\..\\notes.md", "C:\\repo\\project", null],
108
["/repo/project/docs/a/../b.md", "/repo/project", "docs/a/../b.md"],
109
+ ["/repo/a\\b.txt", "/repo", "a\\b.txt"],
110
+ ["/repo/a/b.txt", "/repo", "a/b.txt"],
111
+ ["/repo/a\\", "/repo", "a\\"],
112
+ ["/repo/..\\notes.md", "/repo", "..\\notes.md"],
113
+ ["/repo/a\\/../../notes.md", "/repo", null],
114
+ ["/repo\\project/a.txt", "/repo\\project/", "a.txt"],
115
+ ["/repo/project/a.txt", "/repo\\project", null],
116
+ ["/repo\\project/a.txt", "/repo/project", null],
117
+ ["C:\\Repo\\src\\main.ts", "c:/repo/", "src/main.ts"],
118
+ ["/C:/Repo/src/main.ts", "c:\\repo", "src/main.ts"],
119
+ ["C:\\Repo\\src\\main.ts", "/c:/repo", "src/main.ts"],
120
+ ["\\\\SERVER\\Share\\Repo\\src\\main.ts", "\\\\server\\share\\repo", "src/main.ts"],
121
+ ["\\\\SERVER\\Share\\Repo\\src\\main.ts", "//server/share/repo", "src/main.ts"],
122
+ ["//server/share/a\\b.txt", "//server/share", "a\\b.txt"],
123
+ ["\\\\server\\share\\repo\\..\\notes.md", "\\\\server\\share\\repo", null],
124
])("relates %s to %s", (path, workspaceRoot, relativePath) => {
125
expect(workspaceRelativeFilePath(path, workspaceRoot)).toBe(relativePath);
126
});
packages/shared/src/path.ts
+10
-4
@@ -95,11 +95,17 @@ export function workspaceRelativeFilePath(
95
workspaceRoot: string | null | undefined,
96
): string | null {
97
if (!workspaceRoot) return null;
98
- const normalizedPath = stripSlashPrefixedWindowsDrive(path.replaceAll("\\", "/"));
99
- const normalizedRoot = stripSlashPrefixedWindowsDrive(
100
- workspaceRoot.replaceAll("\\", "/"),
98
+ const caseInsensitive =
99
+ isWindowsAbsolutePath(stripSlashPrefixedWindowsDrive(workspaceRoot)) ||
100
+ (isNetworkPath(workspaceRoot) && isUncPath(path));
101
+ const normalizedPath = caseInsensitive
102
+ ? stripSlashPrefixedWindowsDrive(path.replaceAll("\\", "/"))
103
+ : path;
104
+ const normalizedRoot = (
105
+ caseInsensitive
106
+ ? stripSlashPrefixedWindowsDrive(workspaceRoot.replaceAll("\\", "/"))
107
+ : workspaceRoot
108
).replace(/\/+$/, "");
102
- const caseInsensitive = isWindowsAbsolutePath(stripSlashPrefixedWindowsDrive(workspaceRoot));
109
const pathForCompare = caseInsensitive ? normalizedPath.toLowerCase() : normalizedPath;
110
const rootForCompare = caseInsensitive ? normalizedRoot.toLowerCase() : normalizedRoot;
111
if (pathForCompare.replace(/\/+$/, "") === rootForCompare) return ".";