Auth: Fix phone number formatting, add missing countries (#1010)
This commit is contained in:
parent
d3e05d15ba
commit
6b750c7196
1
src/@types/global.d.ts
vendored
1
src/@types/global.d.ts
vendored
@ -27,6 +27,7 @@ type Country = {
|
|||||||
name: string;
|
name: string;
|
||||||
flag: string;
|
flag: string;
|
||||||
code: string;
|
code: string;
|
||||||
|
phoneFormat: RegExp;
|
||||||
};
|
};
|
||||||
|
|
||||||
type EmojiCategory = {
|
type EmojiCategory = {
|
||||||
|
|||||||
@ -1,197 +1,240 @@
|
|||||||
const DATA = `AF🇦🇫93Afghanistan
|
// This data was received from Telegram Desktop (Telegram/Resources/numbers.txt)
|
||||||
AO🇦🇴244Angola
|
const DATA = `AF🇦🇫93Afghanistan333
|
||||||
AL🇦🇱355Albania
|
AO🇦🇴244Angola333
|
||||||
AD🇦🇩376Andorra
|
AL🇦🇱355Albania234
|
||||||
AE🇦🇪971United Arab Emirates
|
AD🇦🇩376Andorra222
|
||||||
|
AE🇦🇪971United Arab Emirates234
|
||||||
|
AI🇦🇮1264Anguilla34
|
||||||
AR🇦🇷54Argentina
|
AR🇦🇷54Argentina
|
||||||
AM🇦🇲374Armenia
|
AM🇦🇲374Armenia233
|
||||||
AG🇦🇬1268Antigua and Barbuda
|
AG🇦🇬1268Antigua and Barbuda34
|
||||||
AU🇦🇺61Australia
|
AU🇦🇺61Australia333
|
||||||
|
AS🇦🇸1684American Samoa34
|
||||||
AT🇦🇹43Austria
|
AT🇦🇹43Austria
|
||||||
AZ🇦🇿994Azerbaijan
|
AW🇦🇼297Aruba34
|
||||||
BI🇧🇮257Burundi
|
AZ🇦🇿994Azerbaijan2322
|
||||||
BE🇧🇪32Belgium
|
BI🇧🇮257Burundi224
|
||||||
BJ🇧🇯229Benin
|
BE🇧🇪32Belgium3222
|
||||||
BF🇧🇫226Burkina Faso
|
BJ🇧🇯229Benin233
|
||||||
|
BF🇧🇫226Burkina Faso2222
|
||||||
BD🇧🇩880Bangladesh
|
BD🇧🇩880Bangladesh
|
||||||
BG🇧🇬359Bulgaria
|
BG🇧🇬359Bulgaria
|
||||||
BH🇧🇭973Bahrain
|
BH🇧🇭973Bahrain44
|
||||||
BS🇧🇸1242Bahamas
|
BS🇧🇸1242Bahamas34
|
||||||
BA🇧🇦387Bosnia and Herzegovina
|
BA🇧🇦387Bosnia and Herzegovina
|
||||||
BY🇧🇾375Belarus
|
BY🇧🇾375Belarus2322
|
||||||
BZ🇧🇿501Belize
|
BZ🇧🇿501Belize
|
||||||
BO🇧🇴591Bolivia
|
BO🇧🇴591Bolivia134
|
||||||
BR🇧🇷55Brazil
|
BR🇧🇷55Brazil254
|
||||||
BB🇧🇧1246Barbados
|
BB🇧🇧1246Barbados34
|
||||||
BN🇧🇳673Brunei
|
BM🇧🇲1441Bermuda34
|
||||||
|
BN🇧🇳673Brunei34
|
||||||
|
BQ🇧🇶599Bonaire, Sint Eustatius and Saba
|
||||||
BT🇧🇹975Bhutan
|
BT🇧🇹975Bhutan
|
||||||
BW🇧🇼267Botswana
|
BW🇧🇼267Botswana233
|
||||||
CF🇨🇫236Central African Republic
|
CF🇨🇫236Central African Republic2222
|
||||||
CA🇨🇦1Canada
|
CA🇨🇦1Canada334
|
||||||
CH🇨🇭41Switzerland
|
CH🇨🇭41Switzerland234
|
||||||
CL🇨🇱56Chile
|
CK🇨🇰682Cook Islands
|
||||||
CN🇨🇳86China
|
CL🇨🇱56Chile144
|
||||||
CI🇨🇮225Ivory Coast
|
CN🇨🇳86China344
|
||||||
CM🇨🇲237Cameroon
|
CI🇨🇮225Côte d\`Ivoire233
|
||||||
CD🇨🇩243DR Congo
|
CM🇨🇲237Cameroon44
|
||||||
CG🇨🇬242Republic of the Congo
|
CD🇨🇩243DR Congo234
|
||||||
CO🇨🇴57Colombia
|
CG🇨🇬242Republic of the Congo234
|
||||||
KM🇰🇲269Comoros
|
CO🇨🇴57Colombia334
|
||||||
CV🇨🇻238Cape Verde
|
KM🇰🇲269Comoros34
|
||||||
|
CV🇨🇻238Cape Verde34
|
||||||
CR🇨🇷506Costa Rica
|
CR🇨🇷506Costa Rica
|
||||||
CU🇨🇺53Cuba
|
CU🇨🇺53Cuba44
|
||||||
CY🇨🇾357Cyprus
|
CY🇨🇾357Cyprus44
|
||||||
CZ🇨🇿420Czechia
|
CW🇨🇼599Curaçao
|
||||||
DE🇩🇪49Germany
|
CZ🇨🇿420Czech Republic
|
||||||
DJ🇩🇯253Djibouti
|
DE🇩🇪49Germany38
|
||||||
DM🇩🇲1767Dominica
|
DJ🇩🇯253Djibouti2222
|
||||||
DK🇩🇰45Denmark
|
DM🇩🇲1767Dominica34
|
||||||
DO🇩🇴1Dominican Republic
|
DK🇩🇰45Denmark44
|
||||||
DZ🇩🇿213Algeria
|
DO🇩🇴1Dominican Republic334
|
||||||
|
DZ🇩🇿213Algeria3222
|
||||||
EC🇪🇨593Ecuador
|
EC🇪🇨593Ecuador
|
||||||
EG🇪🇬20Egypt
|
EG🇪🇬20Egypt234
|
||||||
ER🇪🇷291Eritrea
|
ER🇪🇷291Eritrea133
|
||||||
ES🇪🇸34Spain
|
ES🇪🇸34Spain333
|
||||||
EE🇪🇪372Estonia
|
EE🇪🇪372Estonia
|
||||||
ET🇪🇹251Ethiopia
|
ET🇪🇹251Ethiopia234
|
||||||
FI🇫🇮358Finland
|
FI🇫🇮358Finland
|
||||||
FJ🇫🇯679Fiji
|
FJ🇫🇯679Fiji
|
||||||
FR🇫🇷33France
|
FK🇫🇰500Falkland Islands
|
||||||
FM🇫🇲691Micronesia
|
FM🇫🇲691Micronesia
|
||||||
GA🇬🇦241Gabon
|
FO🇫🇴298Faroe Islands33
|
||||||
GB🇬🇧44United Kingdom
|
FR🇫🇷33France12222
|
||||||
|
GA🇬🇦241Gabon1222
|
||||||
|
GB🇬🇧44United Kingdom46
|
||||||
GE🇬🇪995Georgia
|
GE🇬🇪995Georgia
|
||||||
|
GF🇬🇫594French Guiana
|
||||||
GH🇬🇭233Ghana
|
GH🇬🇭233Ghana
|
||||||
GN🇬🇳224Guinea
|
GI🇬🇮350Gibraltar44
|
||||||
GM🇬🇲220Gambia
|
GL🇬🇱299Greenland33
|
||||||
GW🇬🇼245Guinea-Bissau
|
GN🇬🇳224Guinea333
|
||||||
GQ🇬🇶240Equatorial Guinea
|
GM🇬🇲220Gambia34
|
||||||
GR🇬🇷30Greece
|
GP🇬🇵590Guadeloupe
|
||||||
GD🇬🇩1473Grenada
|
GU🇬🇺1671Guam34
|
||||||
GT🇬🇹502Guatemala
|
GW🇬🇼245Guinea-Bissau34
|
||||||
|
GQ🇬🇶240Equatorial Guinea333
|
||||||
|
GR🇬🇷30Greece244
|
||||||
|
GD🇬🇩1473Grenada34
|
||||||
|
GT🇬🇹502Guatemala134
|
||||||
GY🇬🇾592Guyana
|
GY🇬🇾592Guyana
|
||||||
HN🇭🇳504Honduras
|
HK🇭🇰852Hong Kong
|
||||||
|
HN🇭🇳504Honduras44
|
||||||
HR🇭🇷385Croatia
|
HR🇭🇷385Croatia
|
||||||
HT🇭🇹509Haiti
|
HT🇭🇹509Haiti
|
||||||
HU🇭🇺36Hungary
|
HU🇭🇺36Hungary234
|
||||||
ID🇮🇩62Indonesia
|
ID🇮🇩62Indonesia
|
||||||
IN🇮🇳91India
|
IN🇮🇳91India55
|
||||||
IE🇮🇪353Ireland
|
IO🇩🇬246Diego Garcia34
|
||||||
IR🇮🇷98Iran
|
IE🇮🇪353Ireland234
|
||||||
IQ🇮🇶964Iraq
|
IR🇮🇷98Iran334
|
||||||
IS🇮🇸354Iceland
|
IQ🇮🇶964Iraq334
|
||||||
IL🇮🇱972Israel
|
IS🇮🇸354Iceland34
|
||||||
IT🇮🇹39Italy
|
IL🇮🇱972Israel234
|
||||||
JM🇯🇲1876Jamaica
|
IT🇮🇹39Italy334
|
||||||
JO🇯🇴962Jordan
|
JM🇯🇲1876Jamaica34
|
||||||
JP🇯🇵81Japan
|
JO🇯🇴962Jordan144
|
||||||
KZ🇰🇿7Kazakhstan
|
JP🇯🇵81Japan244
|
||||||
KE🇰🇪254Kenya
|
KZ🇰🇿7Kazakhstan3322
|
||||||
|
KE🇰🇪254Kenya333
|
||||||
KG🇰🇬996Kyrgyzstan
|
KG🇰🇬996Kyrgyzstan
|
||||||
KH🇰🇭855Cambodia
|
KH🇰🇭855Cambodia
|
||||||
KI🇰🇮686Kiribati
|
KI🇰🇮686Kiribati
|
||||||
KN🇰🇳1869Saint Kitts and Nevis
|
KN🇰🇳1869Saint Kitts and Nevis34
|
||||||
KR🇰🇷82South Korea
|
KR🇰🇷82South Korea
|
||||||
KW🇰🇼965Kuwait
|
KW🇰🇼965Kuwait44
|
||||||
|
KY🇰🇾1345Cayman Islands34
|
||||||
LA🇱🇦856Laos
|
LA🇱🇦856Laos
|
||||||
LB🇱🇧961Lebanon
|
LB🇱🇧961Lebanon
|
||||||
LR🇱🇷231Liberia
|
LR🇱🇷231Liberia
|
||||||
LY🇱🇾218Libya
|
LY🇱🇾218Libya234
|
||||||
LC🇱🇨1758Saint Lucia
|
LC🇱🇨1758Saint Lucia34
|
||||||
LI🇱🇮423Liechtenstein
|
LI🇱🇮423Liechtenstein
|
||||||
LK🇱🇰94Sri Lanka
|
LK🇱🇰94Sri Lanka234
|
||||||
LS🇱🇸266Lesotho
|
LS🇱🇸266Lesotho233
|
||||||
LT🇱🇹370Lithuania
|
LT🇱🇹370Lithuania35
|
||||||
LU🇱🇺352Luxembourg
|
LU🇱🇺352Luxembourg
|
||||||
LV🇱🇻371Latvia
|
LV🇱🇻371Latvia35
|
||||||
MA🇲🇦212Morocco
|
MA🇲🇦212Morocco234
|
||||||
MC🇲🇨377Monaco
|
MC🇲🇨377Monaco44
|
||||||
MD🇲🇩373Moldova
|
MD🇲🇩373Moldova233
|
||||||
MG🇲🇬261Madagascar
|
MG🇲🇬261Madagascar2232
|
||||||
|
MP🇲🇵1670Northern Mariana Islands34
|
||||||
|
MO🇲🇴853Macau
|
||||||
|
MS🇲🇸1664Montserrat34
|
||||||
MV🇲🇻960Maldives
|
MV🇲🇻960Maldives
|
||||||
MX🇲🇽52Mexico
|
MX🇲🇽52Mexico
|
||||||
MH🇲🇭692Marshall Islands
|
MH🇲🇭692Marshall Islands
|
||||||
MK🇲🇰389North Macedonia
|
MK🇲🇰389Macedonia
|
||||||
ML🇲🇱223Mali
|
ML🇲🇱223Mali44
|
||||||
MT🇲🇹356Malta
|
MT🇲🇹356Malta2222
|
||||||
MM🇲🇲95Myanmar
|
MM🇲🇲95Myanmar
|
||||||
ME🇲🇪382Montenegro
|
ME🇲🇪382Montenegro
|
||||||
MN🇲🇳976Mongolia
|
MN🇲🇳976Mongolia
|
||||||
MZ🇲🇿258Mozambique
|
MZ🇲🇿258Mozambique234
|
||||||
MR🇲🇷222Mauritania
|
MQ🇲🇶596Martinique
|
||||||
|
MR🇲🇷222Mauritania44
|
||||||
MU🇲🇺230Mauritius
|
MU🇲🇺230Mauritius
|
||||||
MW🇲🇼265Malawi
|
MW🇲🇼265Malawi
|
||||||
MY🇲🇾60Malaysia
|
MY🇲🇾60Malaysia
|
||||||
NA🇳🇦264Namibia
|
NA🇳🇦264Namibia234
|
||||||
NE🇳🇪227Niger
|
NC🇳🇨687New Caledonia
|
||||||
|
NE🇳🇪227Niger2222
|
||||||
|
NF🇳🇫672Norfolk Island
|
||||||
NG🇳🇬234Nigeria
|
NG🇳🇬234Nigeria
|
||||||
NI🇳🇮505Nicaragua
|
NI🇳🇮505Nicaragua44
|
||||||
NL🇳🇱31Netherlands
|
NL🇳🇱31Netherlands12222
|
||||||
NO🇳🇴47Norway
|
NO🇳🇴47Norway44
|
||||||
NP🇳🇵977Nepal
|
NP🇳🇵977Nepal
|
||||||
|
NU🇳🇺683Niue
|
||||||
NR🇳🇷674Nauru
|
NR🇳🇷674Nauru
|
||||||
NZ🇳🇿64New Zealand
|
NZ🇳🇿64New Zealand
|
||||||
OM🇴🇲968Oman
|
OM🇴🇲968Oman44
|
||||||
PK🇵🇰92Pakistan
|
PK🇵🇰92Pakistan334
|
||||||
PA🇵🇦507Panama
|
PA🇵🇦507Panama44
|
||||||
PE🇵🇪51Peru
|
PE🇵🇪51Peru333
|
||||||
PH🇵🇭63Philippines
|
PF🇵🇫689French Polynesia
|
||||||
|
PH🇵🇭63Philippines334
|
||||||
|
PM🇵🇲508Saint Pierre and Miquelon
|
||||||
|
PR🇵🇷1Puerto Rico334
|
||||||
|
PS🇵🇸970Palestine324
|
||||||
PW🇵🇼680Palau
|
PW🇵🇼680Palau
|
||||||
PG🇵🇬675Papua New Guinea
|
PG🇵🇬675Papua New Guinea
|
||||||
PL🇵🇱48Poland
|
PL🇵🇱48Poland333
|
||||||
KP🇰🇵850North Korea
|
KP🇰🇵850North Korea
|
||||||
PT🇵🇹351Portugal
|
PT🇵🇹351Portugal144
|
||||||
PY🇵🇾595Paraguay
|
PY🇵🇾595Paraguay333
|
||||||
QA🇶🇦974Qatar
|
QA🇶🇦974Qatar
|
||||||
RO🇷🇴40Romania
|
RE🇷🇪262Réunion333
|
||||||
RU🇷🇺7Russia
|
RO🇷🇴40Romania333
|
||||||
RW🇷🇼250Rwanda
|
RU🇷🇺7Russia3322
|
||||||
|
RW🇷🇼250Rwanda333
|
||||||
SA🇸🇦966Saudi Arabia
|
SA🇸🇦966Saudi Arabia
|
||||||
SD🇸🇩249Sudan
|
SD🇸🇩249Sudan234
|
||||||
SN🇸🇳221Senegal
|
SN🇸🇳221Senegal234
|
||||||
SG🇸🇬65Singapore
|
SG🇸🇬65Singapore44
|
||||||
|
SH🇸🇭290Saint Helena23
|
||||||
|
SH🇸🇭247Saint Helena4
|
||||||
SB🇸🇧677Solomon Islands
|
SB🇸🇧677Solomon Islands
|
||||||
SL🇸🇱232Sierra Leone
|
SL🇸🇱232Sierra Leone233
|
||||||
SV🇸🇻503El Salvador
|
SV🇸🇻503El Salvador44
|
||||||
SM🇸🇲378San Marino
|
SM🇸🇲378San Marino334
|
||||||
SO🇸🇴252Somalia
|
SO🇸🇴252Somalia233
|
||||||
RS🇷🇸381Serbia
|
RS🇷🇸381Serbia234
|
||||||
SS🇸🇸211South Sudan
|
SS🇸🇸211South Sudan234
|
||||||
ST🇸🇹239São Tomé and Príncipe
|
ST🇸🇹239São Tomé and Príncipe25
|
||||||
SR🇸🇷597Suriname
|
SR🇸🇷597Suriname34
|
||||||
SK🇸🇰421Slovakia
|
SK🇸🇰421Slovakia
|
||||||
SI🇸🇮386Slovenia
|
SI🇸🇮386Slovenia
|
||||||
SE🇸🇪46Sweden
|
SE🇸🇪46Sweden234
|
||||||
SZ🇸🇿268Eswatini
|
SZ🇸🇿268Swaziland44
|
||||||
SC🇸🇨248Seychelles
|
SC🇸🇨248Seychelles1222
|
||||||
|
SX🇸🇽1721Sint Maarten34
|
||||||
SY🇸🇾963Syria
|
SY🇸🇾963Syria
|
||||||
TD🇹🇩235Chad
|
TC🇹🇨1649Turks and Caicos Islands34
|
||||||
TG🇹🇬228Togo
|
TD🇹🇩235Chad2222
|
||||||
TH🇹🇭66Thailand
|
TG🇹🇬228Togo233
|
||||||
|
TH🇹🇭66Thailand144
|
||||||
TJ🇹🇯992Tajikistan
|
TJ🇹🇯992Tajikistan
|
||||||
TM🇹🇲993Turkmenistan
|
TK🇹🇰690Tokelau
|
||||||
|
TM🇹🇲993Turkmenistan26
|
||||||
TL🇹🇱670Timor-Leste
|
TL🇹🇱670Timor-Leste
|
||||||
TO🇹🇴676Tonga
|
TO🇹🇴676Tonga
|
||||||
TT🇹🇹1868Trinidad and Tobago
|
TT🇹🇹1868Trinidad and Tobago34
|
||||||
TN🇹🇳216Tunisia
|
TN🇹🇳216Tunisia233
|
||||||
TR🇹🇷90Turkey
|
TR🇹🇷90Turkey334
|
||||||
TV🇹🇻688Tuvalu
|
TV🇹🇻688Tuvalu
|
||||||
TZ🇹🇿255Tanzania
|
TW🇹🇼886Taiwan
|
||||||
UG🇺🇬256Uganda
|
TZ🇹🇿255Tanzania234
|
||||||
UA🇺🇦380Ukraine
|
UG🇺🇬256Uganda234
|
||||||
UY🇺🇾598Uruguay
|
UA🇺🇦380Ukraine2322
|
||||||
US🇺🇸1United States
|
UY🇺🇾598Uruguay44
|
||||||
UZ🇺🇿998Uzbekistan
|
US🇺🇸1United States334
|
||||||
|
UZ🇺🇿998Uzbekistan27
|
||||||
VA🇻🇦3Vatican City
|
VA🇻🇦3Vatican City
|
||||||
VC🇻🇨1784Saint Vincent and the Grenadines
|
VC🇻🇨1784Saint Vincent and the Grenadines34
|
||||||
VE🇻🇪58Venezuela
|
VE🇻🇪58Venezuela334
|
||||||
|
VG🇻🇬1284British Virgin Islands34
|
||||||
|
VI🇻🇮1340US Virgin Islands34
|
||||||
VN🇻🇳84Vietnam
|
VN🇻🇳84Vietnam
|
||||||
VU🇻🇺678Vanuatu
|
VU🇻🇺678Vanuatu
|
||||||
|
WF🇼🇫681Wallis and Futuna
|
||||||
WS🇼🇸685Samoa
|
WS🇼🇸685Samoa
|
||||||
YE🇾🇪967Yemen
|
XK🇽🇰383Kosovo44
|
||||||
ZA🇿🇦27South Africa
|
YE🇾🇪967Yemen333
|
||||||
ZM🇿🇲260Zambia
|
ZA🇿🇦27South Africa234
|
||||||
ZW🇿🇼263Zimbabwe`;
|
ZM🇿🇲260Zambia234
|
||||||
|
ZW🇿🇼263Zimbabwe234`;
|
||||||
|
|
||||||
|
const formatsCache: Record<string, RegExp> = {};
|
||||||
|
export const defaultPhoneNumberFormat = /(\d{1,3})(\d{1,3})?(\d{1,3})?(\d{1,3})?(\d{1,3})?/;
|
||||||
|
|
||||||
const parsed = DATA
|
const parsed = DATA
|
||||||
.split('\n')
|
.split('\n')
|
||||||
@ -200,10 +243,31 @@ const parsed = DATA
|
|||||||
const flag = str.substr(2, 4);
|
const flag = str.substr(2, 4);
|
||||||
const code = `+${str.match(/\d+/)![0]}`;
|
const code = `+${str.match(/\d+/)![0]}`;
|
||||||
const name = str.split(/\d+/)[1];
|
const name = str.split(/\d+/)[1];
|
||||||
|
const format = str.match(/\d+$/);
|
||||||
|
const phoneFormat = getPhoneNumberFormat(format);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id, flag, code, name,
|
id, flag, code, name, phoneFormat,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function getPhoneNumberFormat(format: RegExpMatchArray | null) {
|
||||||
|
if (!format) {
|
||||||
|
return defaultPhoneNumberFormat;
|
||||||
|
}
|
||||||
|
|
||||||
|
const formatValue = format[0] as string;
|
||||||
|
let phoneNumberFormat;
|
||||||
|
|
||||||
|
if (!formatsCache[formatValue]) {
|
||||||
|
const phoneNumberGroups = formatValue.split('').map(Number);
|
||||||
|
phoneNumberFormat = phoneNumberGroups.reduce((result, count, i) => {
|
||||||
|
return `${result}(\\d{1,${count}})${i > 0 ? '?' : ''}`;
|
||||||
|
}, '');
|
||||||
|
formatsCache[formatValue] = new RegExp(`${phoneNumberFormat}${'()?'.repeat(5 - phoneNumberGroups.length)}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
return formatsCache[formatValue];
|
||||||
|
}
|
||||||
|
|
||||||
export default parsed;
|
export default parsed;
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import countryList from './countries';
|
import countryList, { defaultPhoneNumberFormat } from './countries';
|
||||||
|
|
||||||
export function getCountryById(id: string) {
|
export function getCountryById(id: string) {
|
||||||
return countryList.find((c) => c.id === id) as Country;
|
return countryList.find((c) => c.id === id) as Country;
|
||||||
@ -6,21 +6,7 @@ export function getCountryById(id: string) {
|
|||||||
|
|
||||||
// Empty groups are used to preserve 5 callback arguments for `replace` method
|
// Empty groups are used to preserve 5 callback arguments for `replace` method
|
||||||
function getPhoneNumberFormat(country?: Country) {
|
function getPhoneNumberFormat(country?: Country) {
|
||||||
const id = country ? country.id : 'UNKNOWN';
|
return country ? country.phoneFormat : defaultPhoneNumberFormat;
|
||||||
|
|
||||||
switch (id) {
|
|
||||||
case 'RU':
|
|
||||||
case 'US':
|
|
||||||
return /(\d{1,3})(\d{1,3})?(\d{1,2})?(\d{1,2})?()?/;
|
|
||||||
case 'GB':
|
|
||||||
return /(\d{1,4})(\d{1,5})?()?()?()?/;
|
|
||||||
case 'UA':
|
|
||||||
case 'FI':
|
|
||||||
case 'AE':
|
|
||||||
return /(\d{1,2})(\d{1,3})?(\d{1,2})?(\d{1,2})?()?/;
|
|
||||||
default:
|
|
||||||
return /(\d{1,3})(\d{1,3})?(\d{1,3})?(\d{1,3})?(\d{1,3})?/;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getCountryFromPhoneNumber(input: string) {
|
export function getCountryFromPhoneNumber(input: string) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user