URISchemaclass
new URISchema({ one = "URI", title = "URI", schemes = HTTP_SCHEMES, input = "url", max = 512, ...options }: URISchemaOptions)| Param | Type | |
|---|---|---|
options | URISchemaOptions | Options for URISchema. required |
.value | string | Default string value used when the input is undefined. readonly |
.max | number | Maximum allowed character length. Defaults to 512 readonly |
.match | RegExp | Regular expression the sanitized string must match. readonly |
.case | "upper""lower" | Force the result to "upper" or "lower" case. readonly |
.input | StringInputType | HTML <input /> type="" hint for downstream UIs. Defaults to "url" readonly |
.schemes | URISchemes | Whitelist of allowed URI schemes. Defaults to HTTP_SCHEMES readonly |
| Return | |
|---|---|
URISchema | Schema that defines a valid absolute URI string. |
| Property | Type | |
|---|---|---|
.schemes | URISchemes | Whitelist of allowed URI schemes, e.g. ["https:", "http:"]. required readonly |
Schema that defines a valid absolute URI string.
- Checks the URI scheme against a whitelist (always).
- URIs are limited to 512 characters, but generally these won't be
data:URIs so this is a reasonable limit.
Examples
const schema = new URISchema({});
schema.validate("https://www.google.com") // "https://www.google.com/"