Skip to content

Commit e899163

Browse files
Fix: Double zero prefix normalization in phoneUtils.ts (#20)
Updated `fixCommonTypos` to handle the `00` prefix early by converting it to `+`. This ensures that subsequent Zimbabwe-specific normalization (removing a leading zero after the country code) can still be applied to inputs like `002630...`. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> Co-authored-by: tapiwamakandigona <230673668+tapiwamakandigona@users.noreply.github.com>
1 parent 3907953 commit e899163

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

src/lib/phoneUtils.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,12 @@ const fixCommonTypos = (phone: string): string => {
1818
if (!phone) return ''
1919

2020
// Remove all non-digit and non-plus chars
21-
const cleaned = phone.replace(/[^\d+]/g, '')
21+
let cleaned = phone.replace(/[^\d+]/g, '')
22+
23+
// Fix: "00263..." -> "+263..." (Double zero prefix)
24+
if (cleaned.startsWith('00')) {
25+
cleaned = '+' + cleaned.substring(2)
26+
}
2227

2328
// Fix: "263077..." -> "26377..." (Common error: Country code + Local leading zero)
2429
if (cleaned.startsWith('2630') && cleaned.length >= 12) {
@@ -30,11 +35,6 @@ const fixCommonTypos = (phone: string): string => {
3035
return '+263' + cleaned.substring(5)
3136
}
3237

33-
// Fix: "00263..." -> "+263..." (Double zero prefix)
34-
if (cleaned.startsWith('00')) {
35-
return '+' + cleaned.substring(2)
36-
}
37-
3838
return cleaned
3939
}
4040

0 commit comments

Comments
 (0)