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

Swedish numbers issue #396

Closed eddie-englund closed 3 years ago

eddie-englund commented 3 years ago

Steps to reproduce

Parse a Swedish phone number with

In Sweden it's common practice to remove the first digit 0 after +46.

Example +46 070 512 61 12

Observed result

Returns as not not valid.

Expected result

What's the expected result?

Expected result is to receive this as successful and the .number value to have an added 0 in the beginning.

Google's demo link

Returns:

Phone Number entered: +46 07+ 512 61 12 defaultCountry entered: SE Language entered: se-SE Error type: NOT_A_NUMBER. The string supplied did not seem to be a phone number.

image

eddie-englund commented 3 years ago

Forget I ever posted this :)

eddie-englund commented 3 years ago

Or actually, I get successful on the demo page, but not in the code.

My check is simple.

    import parsePhoneNumberFromString, { E164Number, PhoneNumber } from "libphonenumber-js";

    const phoneNumber: PhoneNumber | undefined = parsePhoneNumberFromString(_phoneNumber);

image

catamphetamine commented 3 years ago

Provide the exact input to both demos, make screenshots and then compare.

eddie-englund commented 3 years ago

This is what I posted, but you say there's a second demo. I must have missed that.

This is the URL: https://libphonenumber.appspot.com/phonenumberparser?number=%2B46+70+512+61+12&country=SE&geocodingLocale=se-SE

image

catamphetamine commented 3 years ago

Your issue description is not valid. You're passing different numbers. Re-create the issue, I'm closing this one because it's become offtop.

eddie-englund commented 3 years ago

Alright, I'll make a new issue and will provide further info :)