Skip to content

Commit

Permalink
Merge pull request #44515 from nkdengineer/fix/44026
Browse files Browse the repository at this point in the history
fix: Error message when sign up for phone number with a country code
  • Loading branch information
danieldoglas authored Jun 27, 2024
2 parents 9d8e7fe + f67bed9 commit 403cecb
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/libs/LoginUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,14 @@ function getPhoneNumberWithoutSpecialChars(phone: string): string {
* Append user country code to the phone number
*/
function appendCountryCode(phone: string): string {
return phone.startsWith('+') ? phone : `+${countryCodeByIP}${phone}`;
if (phone.startsWith('+')) {
return phone;
}
const phoneWithCountryCode = `+${countryCodeByIP}${phone}`;
if (parsePhoneNumber(phoneWithCountryCode).possible) {
return phoneWithCountryCode;
}
return `+${phone}`;
}

/**
Expand Down

0 comments on commit 403cecb

Please sign in to comment.