libphonenumber-js 1.9.50 → 1.9.53
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -3
- package/build/AsYouType.test.js +17 -2
- package/build/AsYouType.test.js.map +1 -1
- package/build/AsYouTypeFormatter.js +4 -1
- package/build/AsYouTypeFormatter.js.map +1 -1
- package/build/helpers/extractNationalNumber.js +53 -40
- package/build/helpers/extractNationalNumber.js.map +1 -1
- package/build/helpers/extractNationalNumberFromPossiblyIncompleteNumber.js +1 -1
- package/build/helpers/extractNationalNumberFromPossiblyIncompleteNumber.js.map +1 -1
- package/build/parsePhoneNumberFromString.test.js +7 -0
- package/build/parsePhoneNumberFromString.test.js.map +1 -1
- package/bundle/libphonenumber-js.min.js +1 -1
- package/bundle/libphonenumber-js.min.js.map +1 -1
- package/bundle/libphonenumber-max.js +1 -1
- package/bundle/libphonenumber-max.js.map +1 -1
- package/bundle/libphonenumber-min.js +1 -1
- package/bundle/libphonenumber-min.js.map +1 -1
- package/bundle/libphonenumber-mobile.js +1 -1
- package/bundle/libphonenumber-mobile.js.map +1 -1
- package/es6/AsYouType.test.js +17 -2
- package/es6/AsYouType.test.js.map +1 -1
- package/es6/AsYouTypeFormatter.js +4 -1
- package/es6/AsYouTypeFormatter.js.map +1 -1
- package/es6/helpers/extractNationalNumber.js +50 -37
- package/es6/helpers/extractNationalNumber.js.map +1 -1
- package/es6/helpers/extractNationalNumberFromPossiblyIncompleteNumber.js +1 -1
- package/es6/helpers/extractNationalNumberFromPossiblyIncompleteNumber.js.map +1 -1
- package/es6/parsePhoneNumberFromString.test.js +7 -0
- package/es6/parsePhoneNumberFromString.test.js.map +1 -1
- package/index.d.ts +2 -2
- package/metadata.full.json +1 -1
- package/metadata.full.json.js +1 -1
- package/metadata.max.json +1 -1
- package/metadata.max.json.js +1 -1
- package/metadata.min.json +1 -1
- package/metadata.min.json.js +1 -1
- package/metadata.mobile.json +1 -1
- package/metadata.mobile.json.js +1 -1
- package/package.json +1 -1
- package/source/AsYouType.test.js +18 -2
- package/source/AsYouTypeFormatter.js +6 -2
- package/source/helpers/extractNationalNumber.js +49 -35
- package/source/helpers/extractNationalNumberFromPossiblyIncompleteNumber.js +1 -1
- package/source/parsePhoneNumberFromString.test.js +8 -0
- package/types.d.ts +1 -2
package/README.md
CHANGED
|
@@ -1329,7 +1329,33 @@ This package currently [doesn't provide](https://gitlab.com/catamphetamine/libph
|
|
|
1329
1329
|
|
|
1330
1330
|
## Bug reporting
|
|
1331
1331
|
|
|
1332
|
-
|
|
1332
|
+
This library is a simpler rewrite of Google's [`libphonenumber`](https://github.com/google/libphonenumber/blob/master/java/libphonenumber/) library. Basically, it mimicks Google's library behavior. Hence, as long as this library's [demo page](https://catamphetamine.gitlab.io/libphonenumber-js/) and Google's library [demo page](https://libphonenumber.appspot.com/) exhibit the same behavior, it's not considered a bug.
|
|
1333
|
+
|
|
1334
|
+
When reporting issues with:
|
|
1335
|
+
|
|
1336
|
+
* Parsing
|
|
1337
|
+
* Validation
|
|
1338
|
+
* Formatting
|
|
1339
|
+
* "As You Type" formatting
|
|
1340
|
+
|
|
1341
|
+
one must provide two links:
|
|
1342
|
+
|
|
1343
|
+
* A link to the [demo page](https://catamphetamine.gitlab.io/libphonenumber-js/) illustrating the supposedly incorrect behavior.
|
|
1344
|
+
* A link to [Google's `libphonenumber` demo page](https://libphonenumber.appspot.com/) illustrating the expected behavior.
|
|
1345
|
+
|
|
1346
|
+
Google's demo page [outputs four sections](https://libphonenumber.appspot.com/phonenumberparser?number=438331999&country=AU):
|
|
1347
|
+
* "Parsing Result"
|
|
1348
|
+
* "Validation Results"
|
|
1349
|
+
* "Formatting Results"
|
|
1350
|
+
* "AsYouTypeFormatter Results"
|
|
1351
|
+
|
|
1352
|
+
Choose the relevant section of those four corresponding to the type of the bug you're reporting.
|
|
1353
|
+
|
|
1354
|
+
In a bug report:
|
|
1355
|
+
|
|
1356
|
+
* First, describe the observed `libphonenumber-js` demo result (and provide a link to it).
|
|
1357
|
+
* Second, describe the observed Google's demo result (and provide a link to it).
|
|
1358
|
+
* The described observed result of Google's demo must be different from the described observed result of `libphonenumber-js` demo, otherwise it's not considered a bug. If you don't agree with Google's demo result then create an issue in [Google's repo](https://github.com/google/libphonenumber/blob/master/CONTRIBUTING.md) instead. If they fix it in their library, I'll port the fix to this library.
|
|
1333
1359
|
|
|
1334
1360
|
<!--
|
|
1335
1361
|
Phone number validation bugs should **only** be reported if they appear when using [custom metadata functions](#customizing-metadata) fed with `metadata.max.json` because by default all functions in this library use the reduced metadata set which results in looser validation than the original Google `libphonenumber`'s. The [demo page](https://catamphetamine.gitlab.io/libphonenumber-js/) also uses the reduced metadata set and therefore its validation is also looser than the original Google `libphonenumber`'s.
|
|
@@ -1337,7 +1363,7 @@ Phone number validation bugs should **only** be reported if they appear when usi
|
|
|
1337
1363
|
There is also a possibility of this library's demo metadata being outdated, or this library's metadata lagging behind Google's (I have to update it manually from time to time due to `ssh-agent` not working properly on Windows).
|
|
1338
1364
|
-->
|
|
1339
1365
|
|
|
1340
|
-
When reporting `findPhoneNumbersInText()` bugs one should know that `findPhoneNumbersInText()` code was ported from [Google's Java code](https://github.com/googlei18n/libphonenumber/blob/master/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberMatcher.java). I didn't write it myself, I just ported it. Therefore, it is unlikely that anyone other than Google
|
|
1366
|
+
<!-- When reporting `findPhoneNumbersInText()` bugs, one should know that `findPhoneNumbersInText()` code was ported from [Google's Java code](https://github.com/googlei18n/libphonenumber/blob/master/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberMatcher.java). I didn't write it myself, I just ported it. Therefore, it is unlikely that anyone other than Google would fix any bugs. -->
|
|
1341
1367
|
|
|
1342
1368
|
## TypeScript
|
|
1343
1369
|
|
|
@@ -1672,7 +1698,7 @@ Also Google sometimes (very rarely) updates their code:
|
|
|
1672
1698
|
* [`AsYouTypeFormatter.java`](https://github.com/google/libphonenumber/blob/master/java/libphonenumber/src/com/google/i18n/phonenumbers/AsYouTypeFormatter.java) — `AsYouType`
|
|
1673
1699
|
* [`PhoneNumberMatcher.java`](https://github.com/googlei18n/libphonenumber/blob/master/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberMatcher.java) — `findPhoneNumbersInText()`
|
|
1674
1700
|
|
|
1675
|
-
The latest sync-up was on
|
|
1701
|
+
The latest sync-up was on April 24th, 2022.
|
|
1676
1702
|
|
|
1677
1703
|
## Contributing
|
|
1678
1704
|
|
package/build/AsYouType.test.js
CHANGED
|
@@ -654,8 +654,8 @@ describe('AsYouType', function () {
|
|
|
654
654
|
// `1` is prepended before area code to mobile numbers in international format.
|
|
655
655
|
|
|
656
656
|
asYouType.reset();
|
|
657
|
-
asYouType.input('+521331234567').should.equal('+52
|
|
658
|
-
asYouType.getTemplate().should.equal('xxx
|
|
657
|
+
asYouType.input('+521331234567').should.equal('+52 133 1234 567');
|
|
658
|
+
asYouType.getTemplate().should.equal('xxx xxx xxxx xxx'); // Google's `libphonenumber` seems to not able to format this type of number.
|
|
659
659
|
// https://issuetracker.google.com/issues/147938979
|
|
660
660
|
|
|
661
661
|
asYouType.input('8').should.equal('+52 133 1234 5678');
|
|
@@ -1192,6 +1192,21 @@ describe('AsYouType.getNumberValue()', function () {
|
|
|
1192
1192
|
formatter.input('4');
|
|
1193
1193
|
expect(formatter.getNumberValue()).to.be.undefined;
|
|
1194
1194
|
});
|
|
1195
|
+
it('should not drop any input digits', function () {
|
|
1196
|
+
// Test "+529011234567" number, proactively ensuring that no formatting is applied,
|
|
1197
|
+
// where a format is chosen that would otherwise have led to some digits being dropped.
|
|
1198
|
+
var formatter = new AsYouType('MX');
|
|
1199
|
+
formatter.input('9').should.equal('9');
|
|
1200
|
+
formatter.input('0').should.equal('90');
|
|
1201
|
+
formatter.input('1').should.equal('901');
|
|
1202
|
+
formatter.input('1').should.equal('901 1');
|
|
1203
|
+
formatter.input('2').should.equal('901 12');
|
|
1204
|
+
formatter.input('3').should.equal('901 123');
|
|
1205
|
+
formatter.input('4').should.equal('901 123 4');
|
|
1206
|
+
formatter.input('5').should.equal('901 123 45');
|
|
1207
|
+
formatter.input('6').should.equal('901 123 456');
|
|
1208
|
+
formatter.input('7').should.equal('901 123 4567');
|
|
1209
|
+
});
|
|
1195
1210
|
});
|
|
1196
1211
|
|
|
1197
1212
|
function type(something) {
|