Fixed e164Uri utils function

This commit is contained in:
Juha Heinanen
2026-05-13 06:01:22 +03:00
parent 244b47c578
commit b33edb50ab
@@ -189,13 +189,13 @@ object Utils {
} }
fun e164Uri(uri: String, countryCode: String): String { fun e164Uri(uri: String, countryCode: String): String {
if (countryCode == "") return uri
val scheme = uri.take(4) val scheme = uri.take(4)
val userPart = uriUserPart(uri) val userPart = uriUserPart(uri)
return if (userPart.isDigitsOnly()) { return if (userPart.isDigitsOnly()) {
when { when {
userPart.startsWith("00") -> uri.replace("$scheme$userPart", userPart.startsWith("00") -> uri.replace("$scheme$userPart",
scheme + "+" + userPart.substring(2)) scheme + "+" + userPart.substring(2))
countryCode == "" -> uri
userPart.startsWith("0") -> uri.replace("${scheme}0", userPart.startsWith("0") -> uri.replace("${scheme}0",
"$scheme$countryCode") "$scheme$countryCode")
else -> uri.replace(scheme, "$scheme$countryCode") else -> uri.replace(scheme, "$scheme$countryCode")