sanitizeText()function
sanitizeText(str: string): string
| Param | Type | |
|---|---|---|
str | string | The string to sanitize. required |
| Return | |
|---|---|
string | The sanitized single-line string. |
Sanitize a single line of text.
- Used when you're sanitising a single-line input, e.g. a title for something.
- Remove all control characters.
- Normalise runs of whitespace to one
space. - Trim whitespace from the start and end of the string.
Examples
sanitizeText("\x00Nice! ") // "Nice!"