From 6862d34965c1986437eec27debf3c4fbaa975f68 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Sat, 12 Oct 2019 18:11:10 +0200 Subject: [PATCH] Improve username generator (handle unicode conversion properly) Signed-off-by: Thomas Citharel --- js/src/views/Account/children/EditIdentity.vue | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/js/src/views/Account/children/EditIdentity.vue b/js/src/views/Account/children/EditIdentity.vue index 7233b92ea..edcafe955 100644 --- a/js/src/views/Account/children/EditIdentity.vue +++ b/js/src/views/Account/children/EditIdentity.vue @@ -304,9 +304,13 @@ export default class EditIdentity extends Vue { private convertToUsername(value: string | null) { if (!value) return ''; - return value.toLowerCase() + // https://stackoverflow.com/a/37511463 + return value.toLocaleLowerCase() + .normalize('NFD') + .replace(/[\u0300-\u036f]/g, '') .replace(/ /g, '_') - .replace(/[^a-z0-9._]/g, ''); + .replace(/[^a-z0-9._]/g, '') + ; } private async buildVariables() {