MCPcopy Create free account
hub / github.com/block/buzz / resolveFileCard

Function resolveFileCard

desktop/src/shared/ui/markdownFileCard.ts:26–42  ·  view source on GitHub ↗
(
  entry: FileCardImetaEntry | undefined,
  href: string | undefined,
  childText: string,
)

Source from the content-addressed store, hash-verified

24 * link handling.
25 */
26export 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}

Callers 2

createMarkdownComponentsFunction · 0.90

Calls 1

rewriteRelayUrlFunction · 0.90

Tested by

no test coverage detected