Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Use same mastodon regex for usernames

Chocobozzz35a0a924830d
diff --git a/server/helpers/custom-validators/users.ts b/server/helpers/custom-validators/users.ts
index b04970108e..8a6f6fca12 100644
--- a/server/helpers/custom-validators/users.ts
+++ b/server/helpers/custom-validators/users.ts
@@ -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) {