Fix already logged in accounts check

This commit is contained in:
Ilya Laktyushin
2023-03-03 14:38:07 +04:00
parent 4f5d1445ae
commit b1545c9f17
2 changed files with 17 additions and 3 deletions

View File

@@ -5,6 +5,20 @@ import TelegramCore
private let phoneNumberUtil = NBPhoneNumberUtil()
public func cleanPhoneNumber(_ text: String, removePlus: Bool = false) -> String {
var result = ""
for c in text {
if c == "+" && !removePlus {
if result.isEmpty {
result += String(c)
}
} else if c >= "0" && c <= "9" {
result += String(c)
}
}
return result
}
public func formatPhoneNumber(_ string: String) -> String {
do {
let number = try phoneNumberUtil.parse("+" + string, defaultRegion: nil)