Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions index-esm.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -697,9 +697,9 @@ function $a(a,b){for(var c=new z,d,e=a.length,f=0;f<e;++f)d=a.charAt(f),d=b[d.to
function Wb(a){switch(a){case "fixed-line":return 0;case "fixed-line-or-mobile":return 2;case "mobile":return 1;case "pager":return 8;case "personal-number":return 7;case "premium-rate":return 4;case "shared-cost":return 5;case "toll-free":return 3;case "uan":return 9;case "voip":return 6;default:case "unknown":return -1}}
function Xb(a){try{switch(qb(a)){case 0:return "is-possible";case 1:return "invalid-country-code";case 3:return "too-long";case 2:return "too-short"}if(pb(a))return "is-possible"}catch(b){}return "unknown"}
function Yb(a,b){if("+"!==a.charAt(0)&&"00"!==a.slice(0,2))return {parsed:c,v:d};try{var c=mb(P,a,b);}catch(e){}if(c){var d=T(P,c);if(null!=d&&"ZZ"!==d)return {parsed:c,v:d}}for(b=1;4>b;++b){d=void 0;if(a.length<b+1)return {parsed:c,v:d};d=N(a.substring(1,b+1));if("ZZ"!==d)return {v:d}}return {parsed:c,v:void 0}}var Zb;a:{try{Zb=new WeakMap;break a}catch(a){}Zb=void 0;}var $b=Zb;function U(){throw Error("Internal error");}var V=["PhoneNumber$$module$src$index"],W=aa;
V[0]in W||"undefined"==typeof W.execScript||W.execScript("var "+V[0]);for(var X;V.length&&(X=V.shift());)V.length||void 0===U?W[X]&&W[X]!==Object.prototype[X]?W=W[X]:W=W[X]={}:W[X]=U;var ac=Object.freeze({valid:false,possible:false,possibility:"invalid-country-code"});
V[0]in W||"undefined"==typeof W.execScript||W.execScript("var "+V[0]);for(var X;V.length&&(X=V.shift());)V.length||void 0===U?W[X]&&W[X]!==Object.prototype[X]?W=W[X]:W=W[X]={}:W[X]=U;var ac=Object.freeze({valid:false,possible:false,possibility:"invalid-country-code",shortPossible:false,shortValid:false});
function bc(a,b){var c=null==b?void 0:b.regionCode;if("string"===typeof a)var d=false;else try{ob(a),d=!0;}catch(f){d=false;}if(!d&&"string"!==typeof a)throw Error("Invalid phone number, expected a string");if(!d&&"object"!==typeof b&&"undefined"!==typeof b)throw Error(`Invalid options, expected object, got ${typeof b}. `+"This may be because of not yet upgraded code.");if(!d&&null!=c&&"string"!==typeof c)throw Error("Invalid region code, expected a string, got "+`${typeof c} ${c}`);b=null;d?(b=a,c=T(P,b),
a=P.format(b,2)):(a=a.trim(),c&&"+"===a.charAt(0)&&(c=null),c&&"+"!==a.charAt(0)&&"00"!==a.slice(0,2)||({v:c=null,parsed:b}=Yb(a,c)));if(!d){if(c){var e=cc(c);if(0===e)return Object.assign({},ac,c?{regionCode:c}:{})}else return ac;try{b||(b=mb(P,a,c));}catch(f){return Object.assign({},ac,c?{regionCode:c}:{},{error:f})}}return {ra:b,ta:e,Da:a,v:c}}function Y(a){return function(){let b;b||(b=a());return b}}
a=P.format(b,2)):(a=a.trim(),c&&"+"===a.charAt(0)&&(c=null),c&&"+"!==a.charAt(0)&&"00"!==a.slice(0,2)||({v:c=null,parsed:b}=Yb(a,c)));if(!d){if(c){var e=cc(c);if(0===e)return Object.assign({},ac,c?{regionCode:c}:{},{number:{input:a}})}else return Object.assign({},ac,{number:{input:a}});try{b||(b=mb(P,a,c));}catch(f){return Object.assign({},ac,c?{regionCode:c}:{},{error:f,possibility:Xb(a),number:{input:a}})}}return {ra:b,ta:e,Da:a,v:c}}function Y(a){return function(){let b;b||(b=a());return b}}
function dc(a,b){a=bc(a,b);if(!a.ra)return a;let c,d,e;({ra:d,ta:e,Da:a,v:c}=a);a=Object.defineProperties(Object.create(null),{input:{configurable:false,enumerable:true,value:a},international:{configurable:false,enumerable:true,get:Y(()=>P.format(d,1))},national:{configurable:false,enumerable:true,get:Y(()=>P.format(d,2))},e164:{configurable:false,enumerable:true,get:Y(()=>P.format(d,0))},rfc3966:{configurable:false,enumerable:true,get:Y(()=>P.format(d,3))},significant:{configurable:false,enumerable:true,get:Y(()=>L(d))}});b=
Vb(d);var f=ob(d);let g=pb(d);f||g||(g=false);a=Object.defineProperties(Object.create(null),{number:{configurable:false,enumerable:true,value:a},regionCode:{configurable:false,enumerable:true,value:c},valid:{configurable:false,enumerable:true,value:f},possible:{configurable:true,enumerable:true,value:g},possibility:{configurable:true,enumerable:true,get:Y(()=>Xb(d))},shortValid:{configurable:false,enumerable:true,get:Y(()=>{var k=d,n=Ob(u(k,1)),w=Ub(k,n);return 1<n.length&&null!=w?true:Pb(k,w)})},shortPossible:{configurable:false,
enumerable:true,get:Y(()=>{a:{var k=d;var n=Ob(u(k,1));k=Sb(k).length;for(var w=0;w<n.length;w++){var S=Rb(Qb,n[w]);if(S&&r(p(S,1),9).includes(k)){n=true;break a}}n=false;}return n})},type:{configurable:false,enumerable:true,value:b},typeIsMobile:{configurable:false,enumerable:true,value:"mobile"===b||"fixed-line-or-mobile"===b},typeIsFixedLine:{configurable:false,enumerable:true,value:"fixed-line"===b||"fixed-line-or-mobile"===b},canBeInternationallyDialled:{configurable:false,enumerable:true,get:Y(()=>P.ia(d))},countryCode:{configurable:false,
Expand Down
4 changes: 2 additions & 2 deletions lib/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 15 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ const failureSentry = Object.freeze( {
'valid': false,
'possible': false,
'possibility': 'invalid-country-code',
'shortPossible': false,
'shortValid': false,
} );

function parsePhoneNumber( phoneNumber, options )
Expand Down Expand Up @@ -243,7 +245,12 @@ function parsePhoneNumber( phoneNumber, options )
{
if ( !regionCode )
{
return failureSentry;
return {
...failureSentry,
'number': {
'input': phoneNumber
},
};
}
else
{
Expand All @@ -253,6 +260,9 @@ function parsePhoneNumber( phoneNumber, options )
return {
...failureSentry,
...( regionCode ? { 'regionCode': regionCode } : { } ),
'number': {
'input': phoneNumber
},
};
}
}
Expand All @@ -268,6 +278,10 @@ function parsePhoneNumber( phoneNumber, options )
...failureSentry,
...( regionCode ? { 'regionCode': regionCode } : { } ),
'error': e,
'possibility': getValidationResult(phoneNumber),
'number': {
'input': phoneNumber
},
};
}
}
Expand Down