From 830e1ca05267d5bdcc278efa3771e2650964527b Mon Sep 17 00:00:00 2001 From: Yauheni Pasiukevich Date: Wed, 4 Jun 2025 15:28:06 +0200 Subject: [PATCH] Refactor email domain check to use a Set for improved performance --- src/libs/LoginUtils.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libs/LoginUtils.ts b/src/libs/LoginUtils.ts index 646bd00c35af..b900b6286edf 100644 --- a/src/libs/LoginUtils.ts +++ b/src/libs/LoginUtils.ts @@ -8,6 +8,8 @@ import {clearSignInData, setAccountError} from './actions/Session'; import Navigation from './Navigation/Navigation'; import {parsePhoneNumber} from './PhoneNumber'; +const PRIVATE_DOMAINS_SET = new Set(PUBLIC_DOMAINS); + let countryCodeByIP: number; Onyx.connect({ key: ONYXKEYS.COUNTRY_CODE, @@ -40,7 +42,7 @@ function appendCountryCode(phone: string): string { */ function isEmailPublicDomain(email: string): boolean { const emailDomain = Str.extractEmailDomain(email).toLowerCase(); - return (PUBLIC_DOMAINS as readonly string[]).includes(emailDomain); + return PRIVATE_DOMAINS_SET.has(emailDomain); } /**