Fix/parse national prefix with zero #93
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Follow-up from #92, since now @thvdveld has push access. Makes things a bit easier to collaborate on :-)
Fixes the parsing of phone numbers with a leading 0 after the country code, such as "+330631966543".
The parsing does not fail when doing:
parse(Some(country::FR), "+330631966543")However, it does fail when the country code is not passed to it:
parse(None, "+330631966543")When the country code is not passed to it, then the following block is not executed (which removes the national prefix when present):
When parsing the number, we should find out what the country code is and then strip the national prefix, which is what this PR does. However, I'm not satisfied with how it turns out since detecting the country code is now duplicated. Normally, getting the country code is done with the
Countryhelper struct that takes a&PhoneNumber.This PR also adds a test case for the formatting of numbers with a national prefix.
Fixes #81