Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Framasoft
PeerTube
PeerTube
Commits
35a0a924
Verified
Commit
35a0a924
authored
Aug 03, 2022
by
Chocobozzz
Browse files
Use same mastodon regex for usernames
parent
f59462ec
Changes
1
Hide whitespace changes
Inline
Side-by-side
server/helpers/custom-validators/users.ts
View file @
35a0a924
...
...
@@ -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
)
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment