Skip to content

Commit 830e1ca

Browse files
committed
Refactor email domain check to use a Set for improved performance
1 parent ede3398 commit 830e1ca

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/libs/LoginUtils.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import {clearSignInData, setAccountError} from './actions/Session';
88
import Navigation from './Navigation/Navigation';
99
import {parsePhoneNumber} from './PhoneNumber';
1010

11+
const PRIVATE_DOMAINS_SET = new Set(PUBLIC_DOMAINS);
12+
1113
let countryCodeByIP: number;
1214
Onyx.connect({
1315
key: ONYXKEYS.COUNTRY_CODE,
@@ -40,7 +42,7 @@ function appendCountryCode(phone: string): string {
4042
*/
4143
function isEmailPublicDomain(email: string): boolean {
4244
const emailDomain = Str.extractEmailDomain(email).toLowerCase();
43-
return (PUBLIC_DOMAINS as readonly string[]).includes(emailDomain);
45+
return PRIVATE_DOMAINS_SET.has(emailDomain);
4446
}
4547

4648
/**

0 commit comments

Comments
 (0)