dongri / phonenumber

With a given country and phone number, validate and format the MOBILE phone number to E.164 standard
MIT License
181 stars 44 forks source link

fix(land-line): land line overrides iso value due to bad loop breaking #22

Closed ofir5300 closed 2 years ago

ofir5300 commented 2 years ago

break in L#100 is only terminating the inner loop, making the outer loop keeps on running and override the valid value that is found before. Returning i immediately when found resolves this issue

4rakcheev commented 1 year ago

@ofir5300 Hi! Could you please attach an example when the loop appears?

I want to make a test with this case and fix it in a different way because your commit broken other use case (see issue https://github.com/dongri/phonenumber/issues/23)

ofir5300 commented 1 year ago

Hey @4rakcheev, It occured when I was querying US phone number and set landLine to true. package alwasys returned Virgin Island regardless the given phone, for the reason it is the last alphabetical country which matches this line of code

if r.MatchString(number) && len(number) == len(i.CountryCode)+l {