fix: convert space character to non-breaking space on password reveal

converts spaces and a few other characters empty characters into non-breaking spaces so that they'll render properly in the password field.
This commit is contained in:
Aetherinox 2024-04-07 12:46:16 -07:00 committed by GitHub
commit fb6aaff519
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 0 deletions

View File

@ -8,6 +8,11 @@ class RandomNameGenerator {
}
function charCodeToHtml(char) {
// convert certain special chars like space into to non-breaking space
// ' ' to &#nbsp;
if (char === 32 || char === 8193 || char === 8239) {
char = 160;
}
return Math.random() < 0.2 ? String.fromCharCode(char) : `&#x${char.toString(16)};`;
}