@@ -164,7 +164,7 @@ describe("resolveMarkdownMediaPreview", () => {
164164 [ "report.docx" , "document" ] ,
165165 [ "report.xlsx" , "document" ] ,
166166 [ "report.pptx" , "document" ] ,
167- [ "report.unknown" , "document " ] ,
167+ [ "report.unknown" , "image " ] ,
168168 ] ) ( "preserves direct signed embeds: %s" , ( name , kind ) => {
169169 const href = `https://cdn.example.com/${ name } ?signature=a%2fb` ;
170170 expect ( resolveMarkdownMediaPreview ( href , { ...input , imageEmbed : true } ) ) . toMatchObject ( {
@@ -177,11 +177,19 @@ describe("resolveMarkdownMediaPreview", () => {
177177 "https://docs.example.com/guide.html" ,
178178 "https://example.com/index.php?topic=files" ,
179179 "https://example.com/report.unknown" ,
180+ "https://example.com/main.tf" ,
181+ "https://example.com/schema.prisma" ,
182+ "https://example.com/chart.php?id=1" ,
183+ "http://example.com/chart.php?id=1" ,
184+ "//example.com/chart.php?id=1" ,
185+ "https://example.com/chart?format=png" ,
186+ "http://example.com/chart?format=png" ,
187+ "//example.com/chart?format=png" ,
180188 ] ) ( "keeps ordinary remote links in the browser: %s" , ( href ) => {
181189 expect ( resolveMarkdownMediaPreview ( href , input ) ) . toBeNull ( ) ;
182190 expect ( resolveMarkdownMediaPreview ( href , { ...input , imageEmbed : true } ) ) . toMatchObject ( {
183- kind : "document " ,
184- source : { uri : href } ,
191+ kind : "image " ,
192+ source : { uri : href . startsWith ( "//" ) ? `https: ${ href } ` : href } ,
185193 } ) ;
186194 } ) ;
187195
0 commit comments