Constructor
new Sanitizer(configopt)
Constructs the Sanitizer with configuration options.
Parameters:
- Source:
Classes
Methods
sanitize(value) → {string}
Sanitizes a value.
Parameters:
| Name | Type | Description |
|---|---|---|
value |
any | The value to sanitize. |
- Source:
Returns:
The sanitized string.
- Type
- string
(static) sanitizeUrl(url, allowedProtocolsopt) → {string}
Sanitizes a URL string, returning about:blank for disallowed protocols.
Protects applications that bind user-provided URLs to href/src
attributes from javascript: and other pseudo-protocol XSS vectors.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
url |
string | The URL to sanitize. |
|
allowedProtocols |
Array:.<string:> |
<optional> |
Allowed protocols (including the
trailing colon). Defaults to |
- Source:
Returns:
The trimmed URL when its protocol is allowed, or
'about:blank' for disallowed protocols and empty/whitespace input.
- Type
- string
(static) stripTags(html) → {string}
Strips all HTML markup, script/style element content, and HTML comments from a string, returning plain text.
Parameters:
| Name | Type | Description |
|---|---|---|
html |
string | The HTML string from which to strip tags. |
- Source:
Returns:
Plain text with all tags removed.
- Type
- string