catamphetamine / libphonenumber-js

A simpler (and smaller) rewrite of Google Android's libphonenumber library in javascript
https://catamphetamine.gitlab.io/libphonenumber-js/
MIT License
2.77k stars 218 forks source link

findPhoneNumbersInText function does not work as expected when a letter is at the end of the phone number #389

Closed leonardovillela closed 4 years ago

leonardovillela commented 4 years ago

Steps to reproduce

Go to https://npm.runkit.com/libphonenumber-js and call findPhoneNumbersInText function on the string 'a+12025550188a'.

Code snippet used:

var libphonenumberJs = require("libphonenumber-js")
libphonenumberJs.findPhoneNumbersInText('a+12025550188a')

Observed result

An empty array [].

Expected result

An array with a phone number extracted from the text.

Google's demo link

https://libphonenumber.appspot.com/phonenumberparser?number=a%2B12025550188a

leonardovillela commented 4 years ago

First of all thanks for the maintainers of this awesome lib by the work done in it.

If this is really an issue I have the interest to work on a fix 😃

catamphetamine commented 4 years ago

Hi. findPhoneNumbersInText() is not a "parse" function and it only finds "human-readable" phone numbers in "human-readable" text, not in some random string.

leonardovillela commented 4 years ago

HI @catamphetamine, thanks for the answer.

If I remove the last "a" from the text(resulting in: ''a+12025550188") the findPhoneNumbersInText function will find the phone number. My question is, using my example above is this a "human-readable" text?

catamphetamine commented 4 years ago

@leonardovillela Whatever that is, this is most likely how Google implemented it.

leonardovillela commented 4 years ago

It is not, because in google version of libphonenumber the scenario that I described in my first comment works, as you can see on this link. https://libphonenumber.appspot.com/phonenumberparser?number=a%2B12025550188a

catamphetamine commented 4 years ago

It is not, because in google version of libphonenumber the scenario that I described in my first comment works, as you can see on this link.

There seems to be no evidence of that. Perhaps you'd show what exactly do you mean.

leonardovillela commented 4 years ago

The link above is not the evidence? Since it uses google libphonenumber and it finds the phone number from the string 'a+12025550188a'.

catamphetamine commented 4 years ago

@leonardovillela Again, you're not being specific. You're talking about findPhoneNumbersInText() which is a port of Google's findNumbers(). If you provide the evidence that findNumbers() behaves differently than findPhoneNumbersInText() then this could be a bug report. Otherwise, it's just noise.