@@ -21,17 +21,39 @@ describe("rewriteMarkdownFileUriHref", () => {
2121 } ) ;
2222
2323 it ( "normalizes file uri hrefs for windows drive paths" , ( ) => {
24+ const canonicalHref = "/D:/Programme/t3code/apps/web/src/components/chat/OpenInPicker.tsx#L69" ;
2425 expect (
2526 rewriteMarkdownFileUriHref (
2627 "file:///D:/Programme/t3code/apps/web/src/components/chat/OpenInPicker.tsx#L69" ,
2728 ) ,
28- ) . toBe ( "D:/Programme/t3code/apps/web/src/components/chat/OpenInPicker.tsx#L69" ) ;
29+ ) . toBe ( canonicalHref ) ;
30+ expect ( rewriteMarkdownFileUriHref ( canonicalHref ) ) . toBe ( canonicalHref ) ;
2931 } ) ;
3032
3133 it ( "unwraps angle-bracketed file uri hrefs" , ( ) => {
3234 expect (
3335 rewriteMarkdownFileUriHref ( " <file:///D:/Programme/t3code/apps/web/src/markdown-links.ts> " ) ,
34- ) . toBe ( "D:/Programme/t3code/apps/web/src/markdown-links.ts" ) ;
36+ ) . toBe ( "/D:/Programme/t3code/apps/web/src/markdown-links.ts" ) ;
37+ } ) ;
38+
39+ it ( "canonicalizes windows drive hrefs for the custom markdown file renderer" , ( ) => {
40+ expect ( rewriteMarkdownFileUriHref ( "C:/Users/mike/project/src/main.ts:42" ) ) . toBe (
41+ "/C:/Users/mike/project/src/main.ts:42" ,
42+ ) ;
43+ expect ( rewriteMarkdownFileUriHref ( "C:\\Users\\mike\\project\\src\\main.ts:42" ) ) . toBe (
44+ "/C:/Users/mike/project/src/main.ts:42" ,
45+ ) ;
46+ expect ( rewriteMarkdownFileUriHref ( "C:%5CUsers%5Cmike%5Cproject%5Csrc%5Cmain.ts:42" ) ) . toBe (
47+ "/C:/Users/mike/project/src/main.ts:42" ,
48+ ) ;
49+ expect ( rewriteMarkdownFileUriHref ( "C://Users/mike/project/src/main.ts:42" ) ) . toBe (
50+ "/C:/Users/mike/project/src/main.ts:42" ,
51+ ) ;
52+ } ) ;
53+
54+ it ( "ignores non-file hrefs" , ( ) => {
55+ expect ( rewriteMarkdownFileUriHref ( "https://example.com/docs" ) ) . toBeNull ( ) ;
56+ expect ( rewriteMarkdownFileUriHref ( "x:command" ) ) . toBeNull ( ) ;
3557 } ) ;
3658} ) ;
3759
0 commit comments