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

AsYouType not formatting Australian 6-digit numbers w/ leading 13 properly #297

Closed henser closed 5 years ago

henser commented 5 years ago

AsYouType doesn't seem to be formatting Australian "6-digit variable cost fixed line (toll free, premium rate, shared cost)" with leading '13' phone numbers properly. These are being identified as SHARED_COST and are correctly described in the metadata xml and as far as I know they were working properly before.

This is the xml descriptor:

    <!-- 6-digit variable cost fixed line (toll free, premium rate, shared cost) -->
    <numberFormat pattern="(\d{2})(\d{2})(\d{2})">
      <leadingDigits>13</leadingDigits>
      <format>$1 $2 $3</format>
      <intlFormat>NA</intlFormat>
    </numberFormat>

And here's an example in action showing format 13xxxx instead of expected 13 xx xx.

screen shot 2019-02-07 at 11 02 17 am

catamphetamine commented 5 years ago

The reason is that the number you're formatting is a "short code" which aren't formatted by this library.

See the "Differences" section: https://github.com/catamphetamine/libphonenumber-js#difference-from-googles-libphonenumber

        <!-- Premium rate SMS (6 digit) -->
        <numberFormat pattern="(\d{3})(\d{3})">
          <leadingDigits>19</leadingDigits>
          <format>$1 $2</format>
          <intlFormat>NA</intlFormat>
        </numberFormat>