libphonenumber-js 1.10.45 → 1.10.46

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "libphonenumber-js",
3
- "version": "1.10.45",
3
+ "version": "1.10.46",
4
4
  "description": "A simpler (and smaller) rewrite of Google Android's libphonenumber library in javascript",
5
5
  "main": "index.cjs",
6
6
  "module": "index.js",
@@ -20,9 +20,10 @@ export default function getNumberType(input, options, metadata)
20
20
  // code coverage would decrease for some weird reason.
21
21
  options = options || {}
22
22
 
23
- // When `parse()` returned `{}`
24
- // meaning that the phone number is not a valid one.
25
- if (!input.country) {
23
+ // When `parse()` returns an empty object — `{}` —
24
+ // that means that the phone number is malformed,
25
+ // so it can't possibly be valid.
26
+ if (!input.country && !input.countryCallingCode) {
26
27
  return
27
28
  }
28
29
 
@@ -15,4 +15,12 @@ describe('getNumberType', function() {
15
15
  oldMetadata
16
16
  ).should.equal('FIXED_LINE_OR_MOBILE')
17
17
  })
18
+
19
+ it('should return `undefined` when the phone number is a malformed one', function() {
20
+ expect(getNumberType(
21
+ {},
22
+ { v2: true },
23
+ oldMetadata
24
+ )).to.equal(undefined)
25
+ })
18
26
  })
@@ -113,4 +113,8 @@ describe('validate', () => {
113
113
  // National
114
114
  isValidNumber('88005553535 x123', { defaultCountry: 'RU' }).should.equal(true)
115
115
  })
116
+
117
+ it('should validate non-geographic toll-free phone numbers', () => {
118
+ isValidNumber('+80074454123').should.equal(true)
119
+ })
116
120
  })