New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wrong nsn result when trying to parse incomplete number of country with leading digits #35
Comments
The patterns for bermuda are here:
It seems like the pattern is expecting 1 followed by 7 digits (with the first one being between 2 and 8 included) and then adding All in all this fits the parsing rules and the problem seems to be that this block should not be called at all if it was originally a international phone number, which yours is. Which leads me to believe this line should not be called if an exit code was found before https://github.com/cedvdb/phone_numbers_parser/blob/dev/lib/src/parsers/phone_parser.dart#L64
should be surrounded by an if statement |
@cedvdb Thank you for the quick response! I'll probably try to implement the fix and make a PR |
Did you have a stab at it ? |
Sorry, didn't have enough time to dive deeply into it. Tried to implement naive fix, but it feels obviously wrong and even fails for some regions (mostly British overseas territories) |
@nahimilega No timeline from me, although I might have a look next week. I don't believe the fix is that hard though. In the meantime if it's pressing to you, I'll review a PR. |
No it did not work as intended, my comment here should give a rough idea of what's going on: #35 (comment) , but it has to be tested because I remember seeing something that did not work properly, by me or someone else. Just my rough 10 seconds analysis is that this line https://github.com/cedvdb/phone_numbers_parser/blob/dev/lib/src/parsers/phone_parser.dart#L64 should not be called when we know it's an international phone number (there was an exit code or country code). Or alternatively, if there was no national prefix I imagine. Would have to double check how this is supposed to work again for countries like Argentina which have different phone number version for international and national. We just need to know when this method should actually be called and call it accordingly. |
I see. Are there a few test cases you could provide that fail, so I know exactly what the issue is? Or is the code in the reproduction a good test? |
Fixed in version 7.0.1 |
When trying to format incomplete numbers for "as-you-type" formatting, some countries produce wrong numbers by adding excess leading number at some stage. I were able to reproduce it only for countries with existing nationalPrefixTransformRule in metadata.
Code to reproduce
The text was updated successfully, but these errors were encountered: