libphonenumber-js
Advanced tools
Comparing version 0.2.16 to 0.2.17
@@ -334,3 +334,2 @@ 'use strict'; | ||
this.last_match_position = -1; | ||
this.national_prefix_is_part_of_formatting_template = false; | ||
} | ||
@@ -464,8 +463,2 @@ | ||
var number_pattern = this.validate_format(format); | ||
if (!number_pattern) { | ||
continue; | ||
} | ||
if (discard_national_prefix) { | ||
@@ -479,6 +472,18 @@ this.national_number = this.national_prefix + this.national_number; | ||
this.chosen_format = format; | ||
this.create_formatting_template(format, number_pattern); | ||
this.reformat_national_number(); | ||
return (0, _format.format_national_number_using_format)(this.national_number, format, this.is_international(), this.national_prefix, this.country_metadata); | ||
var number_pattern = this.validate_format(format); | ||
var formatted_number = (0, _format.format_national_number_using_format)(this.national_number, format, this.is_international(), this.national_prefix, this.country_metadata); | ||
if (number_pattern) { | ||
// Set `this.template` and `this.partially_populated_template` | ||
this.create_formatting_template(format, number_pattern); | ||
// Populate `this.partially_populated_template` | ||
this.reformat_national_number(); | ||
} else { | ||
this.template = formatted_number.replace(/[\d\+]/g, DIGIT_PLACEHOLDER); | ||
this.partially_populated_template = formatted_number; | ||
} | ||
return formatted_number; | ||
} | ||
@@ -678,3 +683,2 @@ } catch (err) { | ||
var number_format = this.get_format_format(format); | ||
this.national_prefix_is_part_of_formatting_template = false; | ||
@@ -691,3 +695,2 @@ // If the user did input the national prefix | ||
number_format = number_format.replace(_format.FIRST_GROUP_PATTERN, national_prefix_formatting_rule); | ||
this.national_prefix_is_part_of_formatting_template = true; | ||
} | ||
@@ -694,0 +697,0 @@ } |
{ | ||
"name": "libphonenumber-js", | ||
"version": "0.2.16", | ||
"version": "0.2.17", | ||
"description": "A simpler (and smaller) rewrite of Google Android's popular libphonenumber library", | ||
@@ -5,0 +5,0 @@ "main": "index.common.js", |
@@ -377,3 +377,2 @@ // This is an enhanced port of Google Android `libphonenumber`'s | ||
this.last_match_position = -1 | ||
this.national_prefix_is_part_of_formatting_template = false | ||
} | ||
@@ -511,9 +510,2 @@ | ||
const number_pattern = this.validate_format(format) | ||
if (!number_pattern) | ||
{ | ||
continue | ||
} | ||
if (discard_national_prefix) | ||
@@ -528,6 +520,6 @@ { | ||
this.chosen_format = format | ||
this.create_formatting_template(format, number_pattern) | ||
this.reformat_national_number() | ||
return format_national_number_using_format | ||
const number_pattern = this.validate_format(format) | ||
const formatted_number = format_national_number_using_format | ||
( | ||
@@ -540,2 +532,17 @@ this.national_number, | ||
) | ||
if (number_pattern) | ||
{ | ||
// Set `this.template` and `this.partially_populated_template` | ||
this.create_formatting_template(format, number_pattern) | ||
// Populate `this.partially_populated_template` | ||
this.reformat_national_number() | ||
} | ||
else | ||
{ | ||
this.template = formatted_number.replace(/[\d\+]/g, DIGIT_PLACEHOLDER) | ||
this.partially_populated_template = formatted_number | ||
} | ||
return formatted_number | ||
} | ||
@@ -705,3 +712,2 @@ } | ||
let number_format = this.get_format_format(format) | ||
this.national_prefix_is_part_of_formatting_template = false | ||
@@ -720,3 +726,2 @@ // If the user did input the national prefix | ||
number_format = number_format.replace(FIRST_GROUP_PATTERN, national_prefix_formatting_rule) | ||
this.national_prefix_is_part_of_formatting_template = true | ||
} | ||
@@ -723,0 +728,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
1100882
4613