sanitizeWord()function
sanitizeWord(str: string): string
| Param | Type | |
|---|---|---|
str | string | The string to sanitize. required |
| Return | |
|---|---|
string | The sanitized single-word string. |
Sanitize a single word of text.
- Used when you're sanitising a value that can never contain whitespace, e.g. an email address or token.
- Remove all control characters (like
sanitizeText()). - Strip all whitespace entirely (rather than collapsing runs to a single space like
sanitizeText()).
Examples
sanitizeWord("\x00 a b c "); // Returns `"abc"`