@devries-cameron20 / t3code-1 / commits / 9e12eca125
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(shared): relative Windows file links open the file (#33643)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Julius Marminge committed Nov 10, 2026 at 00:00 UTC 9e12eca12526c842f97cfcbc6f3cd2149259c776
2 files changed +24
packages/shared/src/markdownLinks.test.ts
+16
@@ -52,6 +52,7 @@ describe("parseMarkdownFileLink", () => {
52 ["pages/posts/%5Bid%5D.tsx", "pages/posts/[id].tsx"],
53 ["+page.svelte", "+page.svelte"],
54 ["[id].tsx", "[id].tsx"],
55 + ["/\\server\\share\\x.ts", "/\\server\\share\\x.ts"],
56 ])("recognizes %s as a file", (href, path) => {
57 expect(parseMarkdownFileLink(href)?.path).toBe(path);
58 });
@@ -75,6 +76,7 @@ describe("parseMarkdownFileLink", () => {
76 "me@example.com",
77 "foo(bar)",
78 "$HOME",
79 + "\\foo.ts",
80 ])("does not treat %s as a file", (href) => {
81 expect(parseMarkdownFileLink(href)).toBeNull();
82 });
@@ -142,6 +144,20 @@ describe("resolveMarkdownFileLinkTarget", () => {
144 expect(resolveMarkdownFileLinkTarget("patches", "/repo/project")).toBeNull();
145 });
146
147 + // regression: #33625 backslash-separated relative links open the workspace file
148 + it.each([
149 + ["src/Example.cs", "C:\\repo\\src\\Example.cs"],
150 + ["src\\Example.cs", "C:\\repo\\src\\Example.cs"],
151 + ["src%5CExample.cs", "C:\\repo\\src\\Example.cs"],
152 + ["src\\Example.cs:3", "C:\\repo\\src\\Example.cs:3"],
153 + ])("resolves the relative link %s against a windows cwd", (href, target) => {
154 + expect(resolveMarkdownFileLinkTarget(href, "C:\\repo")).toBe(target);
155 + });
156 +
157 + it("keeps a backslash in a relative link that already names a file", () => {
158 + expect(resolveMarkdownFileLinkTarget("./foo%5Cbar.ts", "/repo")).toBe("/repo/./foo\\bar.ts");
159 + });
160 +
161 it("does not treat filename line references as external schemes", () => {
162 expect(resolveMarkdownFileLinkTarget("script.ts:10", "/Users/julius/project")).toBe(
163 "/Users/julius/project/script.ts:10",
packages/shared/src/markdownLinks.ts
+8
@@ -314,6 +314,14 @@ export function parseMarkdownFileLink(href: string): FilePathPosition | null {
314 const hash = safeDecodeURIComponent(source.hash.trim());
315 if (path.length === 0 || hasExternalScheme(path)) return null;
316
317 + const position = parseFilePathLink(path, hash);
318 + // `src\a.ts` is Windows-relative. A link that already parses keeps its spelling, since POSIX
319 + // names may contain `\`; a rooted `\\host` or `\foo` would change root if rewritten.
320 + if (position || /^[\\/]/.test(path) || isWindowsAbsolutePath(path)) return position;
321 + return path.includes("\\") ? parseFilePathLink(path.replaceAll("\\", "/"), hash) : null;
322 +}
323 +
324 +function parseFilePathLink(path: string, hash: string): FilePathPosition | null {
325 const position = splitFilePathPosition(path, hash);
326 return looksLikeFilePath(position.path, path) ? position : null;
327 }