зеркало из https://github.com/mozilla/gecko-dev.git
Bug 869273 - Update PhoneNumber.jsm from upstream. r=gwagner
--HG-- extra : rebase_source : 9a3a3f00c0902e1c4883353ba76d6a77337a38c6
This commit is contained in:
Родитель
ec4b8c6403
Коммит
918d01935e
|
@ -76,6 +76,9 @@ this.PhoneNumber = (function (dataBase) {
|
|||
// representation.
|
||||
function ParseFormat(md) {
|
||||
var formats = md.formats;
|
||||
if (!formats) {
|
||||
return null;
|
||||
}
|
||||
// Bail if we already parsed the format definitions.
|
||||
if (!(Array.isArray(formats[0])))
|
||||
return;
|
||||
|
@ -138,6 +141,9 @@ this.PhoneNumber = (function (dataBase) {
|
|||
// so make sure to parse it now if we haven't already done so.
|
||||
ParseFormat(regionMetaData);
|
||||
var formats = regionMetaData.formats;
|
||||
if (!formats) {
|
||||
return null;
|
||||
}
|
||||
for (var n = 0; n < formats.length; ++n) {
|
||||
var format = formats[n];
|
||||
// The leading digits field is optional. If we don't have it, just
|
||||
|
@ -172,12 +178,14 @@ this.PhoneNumber = (function (dataBase) {
|
|||
// "$NP" will be replaced by the national prefix, and "$FG" with the
|
||||
// first group of numbers.
|
||||
var match = number.match(SPLIT_FIRST_GROUP);
|
||||
var firstGroup = match[1];
|
||||
var rest = match[2];
|
||||
var prefix = nationalPrefixFormattingRule;
|
||||
prefix = prefix.replace("$NP", regionMetaData.nationalPrefix);
|
||||
prefix = prefix.replace("$FG", firstGroup);
|
||||
number = prefix + rest;
|
||||
if (match) {
|
||||
var firstGroup = match[1];
|
||||
var rest = match[2];
|
||||
var prefix = nationalPrefixFormattingRule;
|
||||
prefix = prefix.replace("$NP", regionMetaData.nationalPrefix);
|
||||
prefix = prefix.replace("$FG", firstGroup);
|
||||
number = prefix + rest;
|
||||
}
|
||||
}
|
||||
}
|
||||
return (number == "NA") ? null : number;
|
||||
|
|
Загрузка…
Ссылка в новой задаче