@@ -80,23 +80,42 @@ describe.each([
8080 "obsidian://open?vault=Example&file=Notes" ,
8181] ) ( "ChatMarkdown app deep link %s" , ( href ) => {
8282 it . each ( [ true , false ] ) (
83- "preserves app destinations through the markdown pipeline with parseRawHtml=%s" ,
83+ "preserves app destinations with lowercase and mixed-case schemes with parseRawHtml=%s" ,
8484 async ( parseRawHtml ) => {
8585 vi . stubGlobal ( "IS_REACT_ACT_ENVIRONMENT" , true ) ;
8686 let renderer : ReactTestRenderer | undefined ;
87+ const uppercaseHref = href . replace ( / ^ [ ^ : ] + / , ( scheme ) => scheme . toUpperCase ( ) ) ;
88+ const mixedCaseHref = href . replace ( / ^ ./ , ( letter ) => letter . toUpperCase ( ) ) ;
89+ const text = [
90+ `[Open in app](${ href } )` ,
91+ "[Open][app]" ,
92+ `[app]: ${ uppercaseHref } ` ,
93+ `<${ mixedCaseHref } >` ,
94+ `[Uppercase](${ uppercaseHref } )` ,
95+ "[Unsafe](JAVASCRIPT:alert)" ,
96+ "[Unknown](UNKNOWN://example.com)" ,
97+ ...( parseRawHtml
98+ ? [
99+ `<a href="${ mixedCaseHref } ">HTML app link</a>` ,
100+ '<a href="JAVASCRIPT:alert">Unsafe HTML</a>' ,
101+ ]
102+ : [ ] ) ,
103+ ] . join ( "\n\n" ) ;
87104 try {
88105 await act ( async ( ) => {
89106 renderer = create (
90- < ChatMarkdown
91- cwd = "/workspace/project"
92- text = { `[Open in app](${ href } )\n\n[Open][app]\n\n[app]: ${ href } \n\n<${ href } >\n\n[Unsafe](javascript:alert)\n\n[Unknown](unknown://example.com)` }
93- parseRawHtml = { parseRawHtml }
94- /> ,
107+ < ChatMarkdown cwd = "/workspace/project" text = { text } parseRawHtml = { parseRawHtml } /> ,
95108 ) ;
96109 } ) ;
97110
98111 const destinations = renderer ! . root . findAllByType ( "a" ) . map ( ( link ) => link . props . href ) ;
99- expect ( destinations . filter ( Boolean ) ) . toEqual ( [ href , href , href ] ) ;
112+ expect ( destinations . filter ( Boolean ) ) . toEqual ( [
113+ href ,
114+ parseRawHtml ? href : uppercaseHref ,
115+ parseRawHtml ? href : mixedCaseHref ,
116+ parseRawHtml ? href : uppercaseHref ,
117+ ...( parseRawHtml ? [ href ] : [ ] ) ,
118+ ] ) ;
100119 } finally {
101120 await act ( async ( ) => {
102121 renderer ?. unmount ( ) ;
0 commit comments