Files
piik/src/client/lib/external-link.ts
T
AAA 23eebb4bda fix(markdown): leave incomplete external links as text
Keep the existing external-scheme boundary and validate authored destinations with the URL constructor before creating a link. A missing HTTPS host now preserves the label. Use the constructor available at the browser build baseline instead of introducing URL.canParse.

Validation: the malformed-link regression and the shared chat/release-note suites passed all 12 checks; TypeScript passed. No new URL normalization, protocol or link-fetch behavior was added.
2026-11-24 17:56:35 -05:00

11 lines
279 B
TypeScript

/** Authored content can open ordinary external links, never navigate the App. */
export function isExternalLink(href: string): boolean {
if (!/^(?:https?:\/\/|mailto:)/i.test(href)) return false;
try {
new URL(href);
return true;
} catch {
return false;
}
}