Skip to content

Function: isAllowedUrl() ​

ts
function isAllowedUrl(href, protocols?): boolean;

Whether href is safe to put in a link.

Absolute URLs must use one of protocols. Relative URLs (/path, #id, page.html) are allowed. Control characters and whitespace are removed before the check, because browsers ignore them in the scheme (java\tscript: runs as javascript:).

Parameters ​

ParameterTypeDefault value
hrefstringundefined
protocols?readonly string[]DEFAULT_PROTOCOLS

Returns ​

boolean