diff --git a/apps/flipcash/shared/phone/src/main/kotlin/com/flipcash/app/phone/PhoneUtils.kt b/apps/flipcash/shared/phone/src/main/kotlin/com/flipcash/app/phone/PhoneUtils.kt index aaacb0f6a..d3a70b75b 100644 --- a/apps/flipcash/shared/phone/src/main/kotlin/com/flipcash/app/phone/PhoneUtils.kt +++ b/apps/flipcash/shared/phone/src/main/kotlin/com/flipcash/app/phone/PhoneUtils.kt @@ -88,17 +88,17 @@ class PhoneUtils @Inject constructor( } fun cleanNumber(number: String, locale: CountryLocale): String { - val areaCode = locale.phoneCode - val countryCode =locale.countryCode - val phoneInput = number - - val phoneNumberCombined = areaCode.toString() + phoneInput + val countryCode = locale.countryCode + val javaLocale = Locale(Locale.getDefault().language, countryCode) - val phoneNumber = phoneNumberCombined.makeE164( - Locale(Locale.getDefault().language, countryCode) - ) + if (number.trimStart().startsWith("+")) { + // Already has country code (e.g. from autofill), parse as-is + return number.makeE164(javaLocale) + } - return phoneNumber + val areaCode = locale.phoneCode + val phoneNumberCombined = areaCode.toString() + number + return phoneNumberCombined.makeE164(javaLocale) } private fun String.makeE164(locale: Locale? = null): String {