(url: string | undefined)
| 5 | const SAFE_LINK_PROTOCOLS = new Set(["http:", "https:", "mailto:"]); |
| 6 | |
| 7 | export 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 | |
| 19 | function extractText(node: ReactNode): string { |
| 20 | if (typeof node === "string") return node; |
no outgoing calls
no test coverage detected