Improve converting to username from non-latin characters

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2021-11-09 09:01:40 +01:00
parent a54607a57d
commit cd8a5552bb
4 changed files with 10 additions and 4 deletions

View File

@@ -8,8 +8,10 @@ function convertToUsername(value: string | null): string {
.toLocaleLowerCase()
.normalize("NFD")
.replace(/[\u0300-\u036f]/g, "")
.replace(/\s{2,}/, " ")
.replace(/ /g, "_")
.replace(/[^a-z0-9_]/g, "");
.replace(/[^a-z0-9_]/g, "")
.replace(/_{2,}/, "");
}
function autoUpdateUsername(