@bagelink/vue 1.4.52 → 1.4.54
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -65,7 +65,21 @@ function selectCountry(country: Country) {
|
|
|
65
65
|
activeCountry = country
|
|
66
66
|
open = false
|
|
67
67
|
search = ''
|
|
68
|
-
|
|
68
|
+
|
|
69
|
+
if (!phoneNumber) {
|
|
70
|
+
phoneNumber = `+${activeCountry.dialCode}`
|
|
71
|
+
} else if (phoneNumber.startsWith('+')) {
|
|
72
|
+
// Replace existing country code with the new one
|
|
73
|
+
const existingCountry = countries.find(c => phoneNumber.startsWith(`+${c.dialCode}`))
|
|
74
|
+
if (existingCountry && existingCountry !== country) {
|
|
75
|
+
// Remove the old country code and replace with new one
|
|
76
|
+
const nationalPart = phoneNumber.substring(`+${existingCountry.dialCode}`.length).trim()
|
|
77
|
+
phoneNumber = `+${activeCountry.dialCode}${nationalPart ? ` ${nationalPart}` : ''}`
|
|
78
|
+
}
|
|
79
|
+
} else {
|
|
80
|
+
// Phone number doesn't start with +, prepend the country code
|
|
81
|
+
phoneNumber = `+${activeCountry.dialCode} ${phoneNumber.replace(/^0+/, '')}`
|
|
82
|
+
}
|
|
69
83
|
}
|
|
70
84
|
|
|
71
85
|
async function getIp() {
|