libphonenumber-js
Advanced tools
Comparing version 0.2.14 to 0.2.15
@@ -292,12 +292,4 @@ 'use strict'; | ||
if (this.default_country) { | ||
this.country = this.default_country; | ||
this.country_metadata = _metadata2.default.countries[this.default_country]; | ||
this.country_phone_code = this.country_metadata.phone_code; | ||
this.reset_countriness(); | ||
this.initialize_phone_number_formats_for_this_country_phone_code(); | ||
} else { | ||
this.reset_countriness(); | ||
} | ||
this.reset_format(); | ||
@@ -310,10 +302,27 @@ | ||
}, { | ||
key: 'reset_country', | ||
value: function reset_country() { | ||
if (this.default_country && !this.is_international()) { | ||
this.country = this.default_country; | ||
} else { | ||
this.country = undefined; | ||
} | ||
} | ||
}, { | ||
key: 'reset_countriness', | ||
value: function reset_countriness() { | ||
this.country = undefined; | ||
this.country_metadata = undefined; | ||
this.country_phone_code = undefined; | ||
this.reset_country(); | ||
this.available_formats = []; | ||
this.matching_formats = this.available_formats; | ||
if (this.default_country && !this.is_international()) { | ||
this.country_metadata = _metadata2.default.countries[this.default_country]; | ||
this.country_phone_code = this.country_metadata.phone_code; | ||
this.initialize_phone_number_formats_for_this_country_phone_code(); | ||
} else { | ||
this.country_metadata = undefined; | ||
this.country_phone_code = undefined; | ||
this.available_formats = []; | ||
this.matching_formats = this.available_formats; | ||
} | ||
} | ||
@@ -620,7 +629,3 @@ }, { | ||
if (this.default_country && this.parsed_input && this.parsed_input[0] !== '+') { | ||
this.country = this.default_country; | ||
} else { | ||
this.country = undefined; | ||
} | ||
this.reset_country(); | ||
@@ -780,3 +785,3 @@ // No format matches the national phone number entered | ||
value: function is_international() { | ||
return this.parsed_input[0] === '+'; | ||
return this.parsed_input && this.parsed_input[0] === '+'; | ||
} | ||
@@ -783,0 +788,0 @@ }, { |
{ | ||
"name": "libphonenumber-js", | ||
"version": "0.2.14", | ||
"version": "0.2.15", | ||
"description": "A simpler (and smaller) rewrite of Google Android's popular libphonenumber library", | ||
@@ -5,0 +5,0 @@ "main": "index.common.js", |
@@ -329,15 +329,4 @@ // This is an enhanced port of Google Android `libphonenumber`'s | ||
if (this.default_country) | ||
{ | ||
this.country = this.default_country | ||
this.country_metadata = metadata.countries[this.default_country] | ||
this.country_phone_code = this.country_metadata.phone_code | ||
this.reset_countriness() | ||
this.initialize_phone_number_formats_for_this_country_phone_code() | ||
} | ||
else | ||
{ | ||
this.reset_countriness() | ||
} | ||
this.reset_format() | ||
@@ -350,10 +339,33 @@ | ||
reset_country() | ||
{ | ||
if (this.default_country && !this.is_international()) | ||
{ | ||
this.country = this.default_country | ||
} | ||
else | ||
{ | ||
this.country = undefined | ||
} | ||
} | ||
reset_countriness() | ||
{ | ||
this.country = undefined | ||
this.country_metadata = undefined | ||
this.country_phone_code = undefined | ||
this.reset_country() | ||
this.available_formats = [] | ||
this.matching_formats = this.available_formats | ||
if (this.default_country && !this.is_international()) | ||
{ | ||
this.country_metadata = metadata.countries[this.default_country] | ||
this.country_phone_code = this.country_metadata.phone_code | ||
this.initialize_phone_number_formats_for_this_country_phone_code() | ||
} | ||
else | ||
{ | ||
this.country_metadata = undefined | ||
this.country_phone_code = undefined | ||
this.available_formats = [] | ||
this.matching_formats = this.available_formats | ||
} | ||
} | ||
@@ -639,10 +651,3 @@ | ||
// (or to the default country). | ||
if (this.default_country && this.parsed_input && this.parsed_input[0] !== '+') | ||
{ | ||
this.country = this.default_country | ||
} | ||
else | ||
{ | ||
this.country = undefined | ||
} | ||
this.reset_country() | ||
@@ -792,3 +797,3 @@ // No format matches the national phone number entered | ||
{ | ||
return this.parsed_input[0] === '+' | ||
return this.parsed_input && this.parsed_input[0] === '+' | ||
} | ||
@@ -795,0 +800,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1101368
4619