# sanitizeUrl (@salmonui/rich-text)

> The sanitizeUrl function of @salmonui/rich-text: 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&#x09;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.

Canonical: https://salmonui.dev/docs/reference/rich-text/sanitizeUrl

```ts
import { sanitizeUrl } from '@salmonui/rich-text';
```

Entry index: https://salmonui.dev/docs/reference/rich-text (Markdown with every symbol of the entry: https://salmonui.dev/docs/reference/rich-text.md).

## Reference

Kind: function

```ts
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&#x09;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.
