mirror of
https://github.com/paricafe/misskey.git
synced 2024-11-25 09:36:44 -06:00
Allow hyphens in the middle of remote usernames (#3440)
* Allow hyphens in the middle of remote usernames refs: d797c29db462de4a3d69a5077a1ae4d03195b6f2 * Make options fallback better * Make options flat
This commit is contained in:
parent
1c99ef454b
commit
53c559c001
3 changed files with 4 additions and 4 deletions
|
@ -147,8 +147,8 @@ export const isRemoteUser = (user: any): user is IRemoteUser =>
|
|||
!isLocalUser(user);
|
||||
|
||||
//#region Validators
|
||||
export function validateUsername(username: string): boolean {
|
||||
return typeof username == 'string' && /^[a-zA-Z0-9_]{1,20}$/.test(username);
|
||||
export function validateUsername(username: string, remote?: boolean): boolean {
|
||||
return typeof username == 'string' && (remote ? /^\w+([\w\.-]+\w+)?$/ : /^[a-zA-Z0-9_]{1,20}$/).test(username);
|
||||
}
|
||||
|
||||
export function validatePassword(password: string): boolean {
|
||||
|
|
|
@ -43,7 +43,7 @@ function validatePerson(x: any, uri: string) {
|
|||
return new Error('invalid person: inbox is not a string');
|
||||
}
|
||||
|
||||
if (!validateUsername(x.preferredUsername)) {
|
||||
if (!validateUsername(x.preferredUsername, true)) {
|
||||
return new Error('invalid person: invalid username');
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ export const meta = {
|
|||
};
|
||||
|
||||
export default define(meta, (ps, me) => new Promise(async (res, rej) => {
|
||||
const isUsername = validateUsername(ps.query.replace('@', ''));
|
||||
const isUsername = validateUsername(ps.query.replace('@', ''), true);
|
||||
|
||||
let users: IUser[] = [];
|
||||
|
||||
|
|
Loading…
Reference in a new issue