Use same mastodon regex for usernames

pull/5170/head
Chocobozzz 2022-08-03 10:03:56 +02:00
parent f59462eca4
commit 35a0a92483
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
1 changed files with 3 additions and 3 deletions

View File

@ -27,9 +27,9 @@ function isUserVideoQuotaDailyValid (value: string) {
}
function isUserUsernameValid (value: string) {
const max = USERS_CONSTRAINTS_FIELDS.USERNAME.max
const min = USERS_CONSTRAINTS_FIELDS.USERNAME.min
return exists(value) && validator.matches(value, new RegExp(`^[a-z0-9._]{${min},${max}}$`))
return exists(value) &&
validator.matches(value, new RegExp(`^[a-z0-9_]+([a-z0-9_.-]+[a-z0-9_]+)?$`)) &&
validator.isLength(value, USERS_CONSTRAINTS_FIELDS.USERNAME)
}
function isUserDisplayNameValid (value: string) {