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.81k stars 216 forks source link

Question regarding phone number code parsing #359

Closed floatas closed 5 years ago

floatas commented 5 years ago
  1. +443 throws as too short, however this code isn't present in metadata.
  2. +370 throws invalid country, however this code is in metadata.

Updated test according to my understanding.

  1. Should throw INVALID_COUNTRY
  2. Should throw TOO_SHORT

Is this an issue or I misunderstood how library should work?

catamphetamine commented 5 years ago

+443 throws as too short, however this code isn't present in metadata.

+44 is UK

+370 throws invalid country, however this code is in metadata.

It doesn.t

floatas commented 5 years ago

image

image

floatas commented 5 years ago

Added screenshots, for me it looks like 370 is present in metadata or I'm looking to wrong file.

catamphetamine commented 5 years ago

370 is present in metadata but the error it throws in the latest version is TOO_SHORT. The pull request you've sent — does it pass tests on your machine?

floatas commented 5 years ago

I updated my branch (restored +443 test).

But this test expect(() => parsePhoneNumber('+370')).to.throw('TOO_SHORT') fails on master branch with expected [Function] to throw error including 'TOO_SHORT' but got 'ParseError: INVALID_COUNTRY'

catamphetamine commented 5 years ago

@floatas Indeed, that was a bug. Fixed in libphonenumber-js@1.7.29.

floatas commented 5 years ago

Thank you 👍

catamphetamine commented 5 years ago

Thank you 👍

Well, thank you too then )