MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / sanitizeMarkdownUrl

Function sanitizeMarkdownUrl

packages/react/src/components/markdown.tsx:7–17  ·  view source on GitHub ↗
(url: string | undefined)

Source from the content-addressed store, hash-verified

5const SAFE_LINK_PROTOCOLS = new Set(["http:", "https:", "mailto:"]);
6
7export function sanitizeMarkdownUrl(url: string | undefined): string | null {
8 const trimmed = url?.trim();
9 if (!trimmed || trimmed.startsWith("//")) return null;
10
11 try {
12 const parsed = new URL(trimmed);
13 return SAFE_LINK_PROTOCOLS.has(parsed.protocol) ? parsed.href : null;
14 } catch {
15 return null;
16 }
17}
18
19function extractText(node: ReactNode): string {
20 if (typeof node === "string") return node;

Callers 3

markdown.test.tsFile · 0.90
LinkFunction · 0.85
MarkdownFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected