View as Markdown

API reference: @salmonui/rich-text

sanitizeUrlfunction

import { sanitizeUrl } from '@salmonui/rich-text';
function cleanUrl(raw: string, use: UrlUse): string | null;

Returns the URL to keep for use, or null when it is not allowed. Leading and trailing whitespace and control characters are trimmed and tabs and newlines removed, as browsers do, before the scheme is checked, so java	script: or javascript: are recognized and refused. Allowed: http, https, mailto, tel and relative URLs (including # and //) for links; http, https, blob, relative and data:image/(png|jpeg|gif|webp|avif) for images; http, https, blob and relative for audio and video; embeds are checked by embedAllowed.