@devries-cameron20 / t3code Mirror · read-only / commits / 1ba934798f
Fork 0

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, 13:30 UTC

fix(shared): keep Windows path separators beside ampersands (#36977)

Co-authored-by: Julius Marminge <julius0216@outlook.com>

Tanav Poswal committed Nov 15, 2026 at 05:54 UTC 1ba934798f81d5d0d7852b9bbedb19b221704e07
5 files changed +29 -2
packages/shared/package.json
+1
@@ -591,6 +591,7 @@
591 "mdast-util-to-hast": "^13.2.1",
592 "micromark-extension-directive": "catalog:",
593 "micromark-util-character": "catalog:",
594 + "micromark-util-decode-string": "catalog:",
595 "property-information": "^7.2.0",
596 "rehype-raw": "catalog:",
597 "rehype-sanitize": "catalog:",
packages/shared/src/markdownWindowsPaths.test.ts
+17
@@ -75,3 +75,20 @@ it.each(plugins)("%s finds each escape's word after earlier escapes in the text"
75 ],
76 });
77 });
78 +
79 +it.each([
80 + [String.raw`C:\R&D folder\.t3\shot.png`, String.raw`C:\R&D folder\.t3\shot.png`],
81 + [String.raw`C:\R&amp;D folder\.t3\shot.png`, String.raw`C:\R&D folder\.t3\shot.png`],
82 + [String.raw`C:\work\&stuff\.t3\shot.png`, String.raw`C:\work\&stuff\.t3\shot.png`],
83 + [String.raw`C:\work\&amp;lt;\.t3\shot.png`, String.raw`C:\work\&lt;\.t3\shot.png`],
84 +])("preserves separators and decodes references once in %s", (authored, expected) => {
85 + const parser = unified().use(remarkParse).use(remarkKeepWindowsPaths);
86 + for (const prefix of ["", "!"]) {
87 + expect(parser.parse(`${prefix}[shot](<${authored}>)`)).toMatchObject({
88 + children: [{ children: [{ url: expected }] }],
89 + });
90 + }
91 + expect(parser.parse(`[shot]: <${authored}>`)).toMatchObject({
92 + children: [{ type: "definition", url: expected }],
93 + });
94 +});
packages/shared/src/markdownWindowsPaths.ts
+4 -2
@@ -1,4 +1,5 @@
1 import type { Processor } from "unified";
2 +import { decodeString } from "micromark-util-decode-string";
3 import { isWindowsAbsolutePath } from "./path.ts";
4
5 interface DestinationCompileContext {
@@ -11,9 +12,10 @@ function keepWindowsPathDestination(this: DestinationCompileContext, token: unkn
12 const decoded = this.resume();
13 const authored = this.sliceSerialize(token);
14 const node = this.stack.at(-1);
14 - // Character references still need decoding, so those destinations keep the parsed URL.
15 if (node)
16 - node.url = isWindowsAbsolutePath(authored) && !authored.includes("&") ? authored : decoded;
16 + node.url = isWindowsAbsolutePath(authored)
17 + ? decodeString(authored.replaceAll("\\", "\\\\"))
18 + : decoded;
19 }
20
21 // A drive path that has not reached whitespace yet: `C:`, `C:\Users\me`, `C:/work`.
pnpm-lock.yaml
+6
@@ -224,6 +224,9 @@ catalogs:
224 micromark-util-character:
225 specifier: 2.1.1
226 version: 2.1.1
227 + micromark-util-decode-string:
228 + specifier: 2.0.1
229 + version: 2.0.1
230 micromark-util-types:
231 specifier: 2.0.2
232 version: 2.0.2
@@ -2116,6 +2119,9 @@ importers:
2119 micromark-util-character:
2120 specifier: 'catalog:'
2121 version: 2.1.1
2122 + micromark-util-decode-string:
2123 + specifier: 'catalog:'
2124 + version: 2.0.1
2125 property-information:
2126 specifier: ^7.2.0
2127 version: 7.2.0
pnpm-workspace.yaml
+1
@@ -89,6 +89,7 @@ catalog:
89 mdast-util-directive: 3.1.0
90 micromark-extension-directive: 4.0.0
91 micromark-util-character: 2.1.1
92 + micromark-util-decode-string: 2.0.1
93 micromark-util-types: 2.0.2
94 rehype-raw: 7.0.0
95 rehype-sanitize: 6.0.0