Don't access RemoteConfig directly from 'dumb' components

This commit is contained in:
Scott Nonnenberg 2022-10-24 13:46:36 -07:00 committed by GitHub
parent e79380b37c
commit 0134990275
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
40 changed files with 352 additions and 353 deletions

View file

@ -39,41 +39,3 @@ export function isValidUsername(username: string): boolean {
const [, nickname] = match;
return isValidNickname(nickname);
}
export function getUsernameFromSearch(searchTerm: string): string | undefined {
// Search term contains username if it:
// - Is a valid username with or without a discriminator
// - Starts with @
// - Ends with @
const match = searchTerm.match(
/^(?:(?<valid>[a-z_][0-9a-z_]*(?:\.\d*)?)|@(?<start>.*?)@?|@?(?<end>.*?)?@)$/
);
if (!match) {
return undefined;
}
const { groups } = match;
if (!groups) {
return undefined;
}
return (groups.valid || groups.start || groups.end) ?? undefined;
}
export function getNickname(username: string): string | undefined {
const match = username.match(/^(.*?)(?:\.|$)/);
if (!match) {
return undefined;
}
return match[1];
}
export function getDiscriminator(username: string): string {
const match = username.match(/(\..*)$/);
if (!match) {
return '';
}
return match[1];
}