Skip to content

Commit eb2e68f

Browse files
Zacharonclaude
andcommitted
fix(shared): one-letter link schemes no longer become file links on Windows
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 807319c commit eb2e68f

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

‎packages/shared/src/fileLinks.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ const POSITION_HASH_PATTERN = /^#L(\d+)(?:C(\d+))?$/i;
1717
export function parseFileUrlHref(
1818
href: string,
1919
): { readonly path: string; readonly hash: string } | null {
20+
// Chromium on Windows parses any one-letter scheme as a drive letter
21+
// (`new URL("d:x")` is `file:///D:/x`), so the protocol check alone would turn
22+
// such links into file links only on Windows.
23+
if (!href.trim().toLowerCase().startsWith("file:")) return null;
2024
try {
2125
const parsed = new URL(href);
2226
if (parsed.protocol.toLowerCase() !== "file:") return null;

0 commit comments

Comments
 (0)