Various improvements

This commit is contained in:
Ilya Laktyushin 2024-05-25 16:09:51 +04:00
parent bb5789234c
commit 4d6810c5c0
16 changed files with 149 additions and 56 deletions

View file

@ -5,17 +5,6 @@ import TelegramCore
private let phoneNumberUtil = NBPhoneNumberUtil()
public func enhancePhoneNumberWithCodeFromNumber(_ phoneNumber: String, otherPhoneNumber: String, configuration: CountriesConfiguration) -> String {
guard let (_, code) = lookupCountryIdByNumber(otherPhoneNumber, configuration: configuration) else {
return phoneNumber
}
var cleanNumber = cleanPhoneNumber(phoneNumber)
while cleanNumber.hasPrefix("0") {
cleanNumber.removeFirst()
}
return "+\(code)\(cleanNumber)"
}
public func cleanPhoneNumber(_ text: String, removePlus: Bool = false) -> String {
var result = ""
for c in text {