Reference · Draw a bracket, a table or a road to the final
safeHreffunction
Whether an address may be a link in a drawing: http(s), a relative path or a # fragment. javascript:, data: and every other scheme are refused.
Import it
import { safeHref } from "@johnmorrisdotca/taisen-brackets";
Definition
function safeHref(url: string): boolean
Parameters
| Name | Type | Description |
|---|---|---|
url | string | The address. |
Returns
boolean
true when the address is allowed.
Examples
import { safeHref } from "@johnmorrisdotca/taisen-brackets";
console.log(safeHref("#final"), safeHref("javascript:alert(1)"));true falseWhat it prints (run when this page was built)