libphonenumber-js 1.13.1 → 1.13.3
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/CHANGELOG.md +15 -2
- package/README.md +8 -13
- package/build/isPossible.js +16 -15
- package/build/isPossible.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/isPossible.js +16 -15
- package/es6/isPossible.js.map +1 -1
- package/es6-modern/isPossible.js +16 -15
- package/es6-modern/isPossible.js.map +1 -1
- package/max/metadata/metadata.max.json +1 -1
- package/max/metadata/metadata.max.json.js +1 -1
- 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/min/metadata/metadata.min.json +1 -1
- package/min/metadata/metadata.min.json.js +1 -1
- package/mobile/metadata/metadata.mobile.json +1 -1
- package/mobile/metadata/metadata.mobile.json.js +1 -1
- package/package.json +1 -1
- package/source/isPossible.js +16 -15
package/package.json
CHANGED
package/source/isPossible.js
CHANGED
|
@@ -44,24 +44,25 @@ export default function isPossiblePhoneNumber(input, options, metadata) {
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
// Old metadata (< 1.0.18) had no "possible length" data.
|
|
47
|
+
// Old (legacy) metadata (< 1.0.18) had no "possible length" data.
|
|
48
|
+
// So `isPossibleNumber()` function is supported only for non-legacy metadata.
|
|
48
49
|
if (metadata.possibleLengths()) {
|
|
49
50
|
return isPossibleNumber(input.phone || input.nationalNumber, input.country, metadata)
|
|
50
|
-
} else {
|
|
51
|
-
// There was a bug between `1.7.35` and `1.7.37` where "possible_lengths"
|
|
52
|
-
// were missing for "non-geographical" numbering plans.
|
|
53
|
-
// Just assume the number is possible in such cases:
|
|
54
|
-
// it's unlikely that anyone generated their custom metadata
|
|
55
|
-
// in that short period of time (one day).
|
|
56
|
-
// This code can be removed in some future major version update.
|
|
57
|
-
if (input.countryCallingCode && metadata.isNonGeographicCallingCode(input.countryCallingCode)) {
|
|
58
|
-
// "Non-geographic entities" did't have `possibleLengths`
|
|
59
|
-
// due to a bug in metadata generation process.
|
|
60
|
-
return true
|
|
61
|
-
} else {
|
|
62
|
-
throw new Error('Missing "possibleLengths" in metadata. Perhaps the metadata has been generated before v1.0.18.');
|
|
63
|
-
}
|
|
64
51
|
}
|
|
52
|
+
|
|
53
|
+
// There was a bug in versions from `1.7.35` to `1.7.37` of `libphonenumber-js`
|
|
54
|
+
// where "possible_lengths" property was missing from "non-geographical" numbering plans' metadata.
|
|
55
|
+
// After that, the bug was noticed and fixed.
|
|
56
|
+
// So for versions from `1.7.35` to `1.7.37`, just assume that all "non=geotraphical" numbers are possible.
|
|
57
|
+
// The reason is that the bug was noticed relatively quickly (within a day or so)
|
|
58
|
+
// and it's unlikely that anyone generated their custom metadata in that short time span.
|
|
59
|
+
// And if they didn't generate any custom metadata then a follow-up package update would've silently fixed the bug.
|
|
60
|
+
if (input.countryCallingCode && metadata.isNonGeographicCallingCode(input.countryCallingCode)) {
|
|
61
|
+
return true
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// `isPossibleNumber()` function is not supported.
|
|
65
|
+
throw new Error('Missing "possibleLengths" in metadata. Perhaps the metadata has been generated before v1.0.18.');
|
|
65
66
|
}
|
|
66
67
|
|
|
67
68
|
export function isPossibleNumber(nationalNumber, country, metadata) { //, isInternational) {
|