Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

formatNational not working for some countries in split versions #23

Open
dwbruhn opened this issue Sep 1, 2016 · 4 comments
Open

formatNational not working for some countries in split versions #23

dwbruhn opened this issue Sep 1, 2016 · 4 comments

Comments

@dwbruhn
Copy link
Contributor

dwbruhn commented Sep 1, 2016

formatNational appears to work fine in libphonenumber.js (using the latest files in dist/):

$ node
> require('./libphonenumber.js')
{}
> phoneUtils.formatNational('01212345678', 'GB')
'0121 234 5678'
> phoneUtils.formatNational('2684601234', 'AG')
'(268) 460-1234'

But when I try those two function calls in the country-split versions, only GB works:

> require('./libphonenumber_GB.js')
{}
> phoneUtils.formatNational('01212345678', 'GB')
'0121 234 5678' // formatted
> require('./libphonenumber_AG.js')
{}
> phoneUtils.formatNational('2684601234', 'AG')
'2684601234' // not formatted!

(This is just an initial report...I'll debug further.)

@dwbruhn
Copy link
Contributor Author

dwbruhn commented Sep 1, 2016

Discovered differences in these countries so far. The first line after the country code is the formatted output using libphonenumber.js, while the second is using libphonenumber_XY.js:

AG
(268) 460-1234
2684601234

AI
(264) 461-2345
2644612345

AS
(684) 622-1234
6846221234

AX
018 12345678
1812345678

BB
(246) 412-3456
2464123456

BL
0590 27-1234
590271234

BM
(441) 234-5678
4412345678

BQ
715 1234
7151234

BS
(242) 345-6789
2423456789

CA
(204) 234-5678
2042345678

CC
(08) 9162 1234
891621234

CX
(08) 9164 1234
891641234

DM
(767) 420-1234
7674201234

DO
(809) 234-5678
8092345678

EH
05288-12345
528812345

GD
(473) 269-1234
4732691234

GG
01481 456789
1481456789

GU
(671) 300-1234
6713001234

etc.

Mostly smaller territories. Perhaps they're dependent on the metadata of a parent territory (e.g. GU Guam)?

@nathanhammond
Copy link
Owner

I'm unsure why any of those would be failing. Truth be told I know ~0 about libphonenumber or the build stuff. 😜 It worked as a single-module include for the scenario I needed.

If you track down how to fix it I'm all ears, though!

@dwbruhn
Copy link
Contributor Author

dwbruhn commented Sep 1, 2016

Sure, I'll let you know what I find out! My hunch is that metadata for countries sharing the same calling code may need to be bundled...notice, for example, that CC and CX fail to format, both of which share calling code 61 with AU. The same happens with this list of countries, all of which share calling code 1 with the US:

[ 'AG', 'AI', 'AS', 'BB', 'BM', 'BS', 'CA', 'DM', 'DO', 'GD', 'GU', 'JM', 'KN', 'KY', 'LC', 'MF', 'MP', 'MS', 'PR', 'SX', 'TC', 'TT', 'VC', 'VG', 'VI' ]

@dwbruhn
Copy link
Contributor Author

dwbruhn commented Sep 1, 2016

I think that's it! As soon as I bundled the US metadata with AG, for instance, libphonenumber_AG.js started formatting the same as libphonenumber.js:

AG                                                                                                                                                                                               
(268) 460-1234                                                                                                                                                                                   
(268) 460-1234   

I'll submit a PR once I've got it all figured out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants