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 21, 16:00 UTC
fix(shared): one-letter link schemes no longer become file links on Windows (#24006)
Co-authored-by: Julius Marminge <julius0216@outlook.com>
Zach committed
Nov 14, 2026 at 04:09 UTC
a61291e3e2c401852454b701e82278847c9c4ab1
2 files changed
+15
packages/shared/src/fileLinks.test.ts
+11
@@ -103,6 +103,17 @@ describe("parseFileUrlHref", () => {
103
it.each(["https://example.com/a.ts", "file://%", "/Users/julius/a.ts"])("rejects %s", (href) => {
104
expect(parseFileUrlHref(href)).toBeNull();
105
});
106
+
107
+ it("rejects one-letter schemes that Chromium on Windows reads as drive letters", () => {
108
+ const NativeURL = URL;
109
+ using _url = vi.spyOn(globalThis, "URL").mockImplementation(function (input: string | URL) {
110
+ const drive = /^([a-z]):/i.exec(String(input));
111
+ return drive
112
+ ? new NativeURL(`file:///${drive[1]!.toUpperCase()}:/${String(input).slice(2)}`)
113
+ : new NativeURL(input);
114
+ });
115
+ expect(parseFileUrlHref("d:x")).toBeNull();
116
+ });
117
});
118
119
describe("splitFilePathPosition", () => {
packages/shared/src/fileLinks.ts
+4
@@ -13,6 +13,10 @@ const POSITION_HASH_PATTERN = /^#L(\d+)(?:C(\d+)|-L?(\d+))?$/i;
13
export function parseFileUrlHref(
14
href: string,
15
): { readonly path: string; readonly hash: string } | null {
16
+ // Chromium on Windows parses any one-letter scheme as a drive letter
17
+ // (`new URL("d:x")` is `file:///D:/x`), so the protocol check alone would turn
18
+ // such links into file links only on Windows.
19
+ if (!href.trim().toLowerCase().startsWith("file:")) return null;
20
try {
21
const parsed = new URL(href);
22
if (parsed.protocol.toLowerCase() !== "file:") return null;