( entry: FileCardImetaEntry | undefined, href: string | undefined, childText: string, )
| 24 | * link handling. |
| 25 | */ |
| 26 | export function resolveFileCard( |
| 27 | entry: FileCardImetaEntry | undefined, |
| 28 | href: string | undefined, |
| 29 | childText: string, |
| 30 | ): ResolvedFileCard | null { |
| 31 | if ( |
| 32 | !href || |
| 33 | !entry?.m || |
| 34 | entry.m.startsWith("image/") || |
| 35 | entry.m.startsWith("video/") |
| 36 | ) { |
| 37 | return null; |
| 38 | } |
| 39 | const filename = |
| 40 | entry.filename || childText.trim() || href.split("/").pop() || "file"; |
| 41 | return { href: rewriteRelayUrl(href), filename, size: entry.size }; |
| 42 | } |
no test coverage detected