From cd8a5552bb90006068c04a411fcedd3196e489f0 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Tue, 9 Nov 2021 09:01:40 +0100 Subject: [PATCH] Improve converting to username from non-latin characters Signed-off-by: Thomas Citharel --- js/src/i18n/en_US.json | 3 ++- js/src/i18n/fr_FR.json | 3 ++- js/src/mixins/identityEdition.ts | 4 +++- js/src/utils/username.ts | 4 +++- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/js/src/i18n/en_US.json b/js/src/i18n/en_US.json index 98c5994af..66276437d 100644 --- a/js/src/i18n/en_US.json +++ b/js/src/i18n/en_US.json @@ -1232,5 +1232,6 @@ "View full profile": "View full profile", "Any type": "Any type", "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." } diff --git a/js/src/i18n/fr_FR.json b/js/src/i18n/fr_FR.json index d1b380733..a4e63e70c 100644 --- a/js/src/i18n/fr_FR.json +++ b/js/src/i18n/fr_FR.json @@ -1336,5 +1336,6 @@ "View full profile": "Voir le profil complet", "Any type": "N'importe quel type", "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." } diff --git a/js/src/mixins/identityEdition.ts b/js/src/mixins/identityEdition.ts index 246b423ce..f3e0a2282 100644 --- a/js/src/mixins/identityEdition.ts +++ b/js/src/mixins/identityEdition.ts @@ -29,8 +29,10 @@ export default class IdentityEditionMixin extends Mixins(Vue) { .toLocaleLowerCase() .normalize("NFD") .replace(/[\u0300-\u036f]/g, "") + .replace(/\s{2,}/, " ") .replace(/ /g, "_") - .replace(/[^a-z0-9_]/g, ""); + .replace(/[^a-z0-9_]/g, "") + .replace(/_{2,}/, ""); } validateUsername(): boolean { diff --git a/js/src/utils/username.ts b/js/src/utils/username.ts index 2b51a4c0e..aaf3bb1e7 100644 --- a/js/src/utils/username.ts +++ b/js/src/utils/username.ts @@ -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(