-
Notifications
You must be signed in to change notification settings - Fork 295
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ui): Format safe identifier phone number during sign in verificat…
…ion step (#3751)
- Loading branch information
1 parent
e884aad
commit a0f37ef
Showing
2 changed files
with
21 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { stringToFormattedPhoneString } from '~/common/phone-number-field/utils'; | ||
|
||
export const isMaskedIdentifier = (str: string | undefined | null) => str && str.includes('**'); | ||
|
||
/** | ||
* Formats a string that can contain an email, a username or a phone number. | ||
* Depending on the scenario, the string might be obfuscated (parts of the identifier replaced with "*") | ||
* Refer to the tests for examples. | ||
*/ | ||
export const formatSafeIdentifier = (str: string | undefined | null) => { | ||
if (!str || str.includes('@') || isMaskedIdentifier(str) || str.match(/[a-zA-Z]/)) { | ||
return str; | ||
} | ||
return stringToFormattedPhoneString(str); | ||
}; |