13 lines
369 B
JavaScript
13 lines
369 B
JavaScript
|
export default function (phone, prefix = 34) {
|
||
|
if (phone.startsWith('+')) {
|
||
|
return `${phone.slice(1)}`;
|
||
|
}
|
||
|
if (phone.startsWith('00')) {
|
||
|
return `${phone.slice(2)}`;
|
||
|
}
|
||
|
if (phone.startsWith(prefix) && phone.length === prefix.length + 9) {
|
||
|
return `${prefix}${phone.slice(prefix.length)}`;
|
||
|
}
|
||
|
return `${prefix}${phone}`;
|
||
|
}
|