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 217 forks source link

Wrong national formatting for French numbers. #190

Closed naoisegolden closed 6 years ago

naoisegolden commented 6 years ago

I am experiencing wrong formatting for French numbers when using the National formatting option.

I have quite a convoluted code (for reasons beyond this issue) which may be the cause, but all other numbers I tried (ES and US) format correctly, so I wonder if this is happening to other people or is a known bug?

import { format, AsYouType } from 'libphonenumber-js';

function formatValue(value, country) {
  const formatter = new AsYouType(country);
  formatter.input(value);

  const formattedValue = (new AsYouType(country)).input(formatter.getNationalNumber());
  console.log(formattedValue);
}

formatValue('+33624322683', 'FR');
// > 624322666
// should be '06 24 32 26 66'
catamphetamine commented 6 years ago

Your code is very complicated. Reduce it to a simple test case and create a PR in AsYouType.test.js if you think it's failing.

naoisegolden commented 6 years ago

Thanks. That was fast (and not useful at all).

catamphetamine commented 6 years ago

Good riddance