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
No known key found for this signature in database
GPG key ID: A061B9DDE0CA0773
4 changed files with 10 additions and 4 deletions

View file

@ -1232,5 +1232,6 @@
"View full profile": "View full profile", "View full profile": "View full profile",
"Any type": "Any type", "Any type": "Any type",
"In person": "In person", "In person": "In person",
"In the past": "In the past" "In the past": "In the past",
"Only registered users may fetch remote events from their URL.": "Only registered users may fetch remote events from their URL."
} }

View file

@ -1336,5 +1336,6 @@
"View full profile": "Voir le profil complet", "View full profile": "Voir le profil complet",
"Any type": "N'importe quel type", "Any type": "N'importe quel type",
"In person": "En personne", "In person": "En personne",
"In the past": "Dans le passé" "In the past": "Dans le passé",
"Only registered users may fetch remote events from their URL.": "Seul⋅es les utilisateur⋅ices enregistré⋅es peuvent récupérer des événements depuis leur URL."
} }

View file

@ -29,8 +29,10 @@ export default class IdentityEditionMixin extends Mixins(Vue) {
.toLocaleLowerCase() .toLocaleLowerCase()
.normalize("NFD") .normalize("NFD")
.replace(/[\u0300-\u036f]/g, "") .replace(/[\u0300-\u036f]/g, "")
.replace(/\s{2,}/, " ")
.replace(/ /g, "_") .replace(/ /g, "_")
.replace(/[^a-z0-9_]/g, ""); .replace(/[^a-z0-9_]/g, "")
.replace(/_{2,}/, "");
} }
validateUsername(): boolean { validateUsername(): boolean {

View file

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