Merge branch 'bug/improve-username-generator' into 'master'

Improve username generator (handle unicode conversion properly)

See merge request framasoft/mobilizon!255
This commit is contained in:
Thomas Citharel 2019-10-12 18:55:19 +02:00
commit b0cab822bb

View File

@ -304,9 +304,13 @@ export default class EditIdentity extends Vue {
private convertToUsername(value: string | null) { private convertToUsername(value: string | null) {
if (!value) return ''; if (!value) return '';
return value.toLowerCase() // https://stackoverflow.com/a/37511463
return value.toLocaleLowerCase()
.normalize('NFD')
.replace(/[\u0300-\u036f]/g, '')
.replace(/ /g, '_') .replace(/ /g, '_')
.replace(/[^a-z0-9._]/g, ''); .replace(/[^a-z0-9._]/g, '')
;
} }
private async buildVariables() { private async buildVariables() {