You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
According to the documentation, if the pattern is suggesting that the number should have length of 7 or 10, and when the number actually has length of 8, this function will return TOO_LONG.
// Helper method to check a number against a particular pattern and
// determine whether it matches, or is too short or too long. Currently,
// if a number pattern suggests that numbers of length 7 and 10 are
// possible, and a number in between these possible lengths is entered,
// such as of length 8, this will return TOO_LONG.
But in the current implementation, it's returning TOO_SHORT.
inds := numberPattern.FindStringIndex(number)
if len(inds) > 0 && inds[0] == 0 && inds[1] == len(number) {
if inds[1] == len(number) { // Exact match
return IS_POSSIBLE
}
return TOO_LONG // Matches input start but not end
}
return TOO_SHORT // Does not match input start
This leads to a weird behavior of duplicating the last digit when a phone number is hence categorized as too long. For example, +1 951178619 will be parsed and formatted into +1 951-178-6199.
The text was updated successfully, but these errors were encountered:
jvictorchen
added a commit
to jvictorchen/libphonenumber
that referenced
this issue
Sep 2, 2016
* Fix a bug raised in issue #32
See #32 for more details
* Correct the logic in the previous bug fix
* Correct the logic in the previous bug fix
* Add tests for testNumberLengthAgainstPattern
According to the documentation, if the pattern is suggesting that the number should have length of 7 or 10, and when the number actually has length of 8, this function will return TOO_LONG.
But in the current implementation, it's returning TOO_SHORT.
This leads to a weird behavior of duplicating the last digit when a phone number is hence categorized as too long. For example, +1 951178619 will be parsed and formatted into +1 951-178-6199.
The text was updated successfully, but these errors were encountered: