mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-05-08 08:58:38 +01:00
Discriminator in username
This commit is contained in:
+9
-19
@@ -1,23 +1,13 @@
|
||||
// Copyright 2021 Signal Messenger, LLC
|
||||
// Copyright 2022 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
export const MAX_USERNAME = 26;
|
||||
export const MIN_USERNAME = 4;
|
||||
export type UsernameReservationType = Readonly<{
|
||||
username: string;
|
||||
previousUsername: string | undefined;
|
||||
reservationToken: string;
|
||||
}>;
|
||||
|
||||
export function isValidUsername(searchTerm: string): boolean {
|
||||
return /^[a-z_][0-9a-z_]{3,25}$/.test(searchTerm);
|
||||
}
|
||||
|
||||
export function getUsernameFromSearch(searchTerm: string): string | undefined {
|
||||
if (/^[+0-9]+$/.test(searchTerm)) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const match = /^@?(.*?)@?$/.exec(searchTerm);
|
||||
|
||||
if (match && match[1]) {
|
||||
return match[1];
|
||||
}
|
||||
|
||||
return undefined;
|
||||
export enum ReserveUsernameError {
|
||||
Unprocessable = 'Unprocessable',
|
||||
Conflict = 'Conflict',
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user