CountryCodePickerProject icon indicating copy to clipboard operation
CountryCodePickerProject copied to clipboard

detectCarrierNumber needs improvement on the algorithm

Open fatma12 opened this issue 4 years ago • 3 comments

fatma12 avatar Mar 02 '21 04:03 fatma12

Hi, I am using 2.4.6 version of the library. Here is a bug that I want to report. Here is the scenario: lets say that we are in Australia. Our code is +61. I have a contact which has 0431564613. DetectCarrierNumber function detects the "61" from end of the number and takes it as country number and setFullNumber function only sets 3 into my edit text instead of 0431564613. Normally it should detect "61" if it is at the beginning of the number. But it detects "61" even if its in the end of the number and returns carrier number as whatever number we have after 61. Thanks!

fatma12 avatar Mar 02 '21 04:03 fatma12

Trying to understand the scenario. So is leading 0 From 0431564613 part of international phone format or national format? And detectCarrierNumber expects input in international format. What do you get if you pass "+61431564613" to detectCarrierNumber?

On Mon, Mar 1, 2021 at 21:20 Fatma Akyldrm [email protected] wrote:

Hi, I am using 2.4.6 version of the library. Here is a bug that I want to report. Here is the scenario: lets say that we are in Australia. Our code is +61. I have a contact which has 0431564613. DetectCarrierNumber function detects the "61" from end of the number and takes it as country number and setFullNumber function only sets 3 into my edit text instead of 0431564613. Normally it should detect "61" if it is at the beginning of the number. But it detects "61" even if its in the end of the number and returns carrier number as whatever number we have after 61. Thanks!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/hbb20/CountryCodePickerProject/issues/471#issuecomment-788568701, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABFQ32AA7H3NMFYNERIU4NTTBRRQHANCNFSM4YN6KI5Q .

hbb20 avatar Mar 02 '21 06:03 hbb20

steps to reproduce:

when country picker is default to AU (+61) and setFullNumber function.

add 0431761567 into your contact on your phone. and try to auto-fill this contact into edit text with setFullNumber function. you will see 567 which is last 3 digits instead of 0431761567 in the edit text.

The reason is this number contains "61" in the middle. 61 is the country code in AU. Your detectCarrierNumber function takes 61 as country code and takes the rest of the number as carrier number. So this is the issue. The code should not detect if the 61 in the middle of the full number. If its in the beginning it should detect only.

fatma12 avatar Mar 02 '21 22:03 fatma12