forked from upstream-mirrors/quik
fix(utils): Allow characters to be included after normalizing numbers
Android's normalizing function stripped out characters too aggressively leading to false matches between different numbers. This commit introduces a faster normalizing function that includes characters.
This commit is contained in:
@@ -69,4 +69,14 @@ class PhoneNumberUtilsTest {
|
||||
assertFalse(phoneNumberUtils.compare("123 456 7890", "234 567 8901"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun compare_formatted_SenderID_returnsTrue() {
|
||||
assertTrue(phoneNumberUtils.compare("Vi-CARE-S", "ViCARES"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun compare_different_SenderID_returnsFalse() {
|
||||
assertFalse(phoneNumberUtils.compare("VM-ViCARE-S", "VZ-ViCARE-S"))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -68,9 +68,8 @@ class PhoneNumberUtils @Inject constructor(context: Context) {
|
||||
return PhoneNumberUtils.formatNumber(number.toString(), countryCode) ?: number.toString()
|
||||
}
|
||||
|
||||
fun normalizeNumber(number: String): String {
|
||||
return PhoneNumberUtils.stripSeparators(number)
|
||||
}
|
||||
fun normalizeNumber(number: String): String =
|
||||
number.filter { it.isLetterOrDigit() || it in "+*#" }
|
||||
|
||||
private fun parse(number: CharSequence): Phonenumber.PhoneNumber? {
|
||||
return tryOrNull(false) { phoneNumberUtil.parse(number, countryCode) }
|
||||
|
||||
Reference in New Issue
Block a user