@@ -571,6 +571,16 @@ def normalize_regional_phone_numbers(self, phone: str, region: str) -> str:
571571 "AT" : "43" ,
572572 }
573573
574+ # Handle leading zero in local numbers
575+ if region not in ["US" , "CA" ] and phone .startswith ("0" ):
576+ # Remove the leading zero
577+ phone = phone [1 :]
578+
579+ # Fix Austrian phone number duplication issue before processing
580+ if region == "AT" and "4343" in phone :
581+ # Remove the duplicated country code
582+ phone = phone .replace ("4343" , "43" )
583+
574584 # If phone is already normalized, return as it is
575585 expected_country_code = country_codes .get (region )
576586 if (
@@ -581,11 +591,6 @@ def normalize_regional_phone_numbers(self, phone: str, region: str) -> str:
581591 ):
582592 return phone
583593
584- # Fix Austrian phone number duplication issue before processing
585- if region == "AT" and "4343" in phone :
586- # Remove the duplicated country code
587- phone = phone .replace ("4343" , "43" )
588-
589594 # Sub out anything that matches this regex statement with an empty string to get rid of extensions in generated phone numbers
590595 phone = re .sub (r"\s*(?:x|ext)\s*\d*$" , "" , phone , flags = re .IGNORECASE )
591596 # Sub out anything that is not a digit with the empty string to ensure the phone number is formatted with no spaces or special characters
@@ -603,11 +608,6 @@ def normalize_regional_phone_numbers(self, phone: str, region: str) -> str:
603608 # Remove country code from the local number
604609 local_number = digits [len (country_code ) :]
605610
606- # Handle leading zero in local numbers
607- if region not in ["US" , "CA" ] and local_number .startswith ("0" ):
608- # Remove the leading zero
609- local_number = local_number [1 :]
610-
611611 # Validate local number length
612612 if len (local_number ) < 6 : # Too short to be valid
613613 logging .warning (f"Invalid phone number format: { phone } " )
0 commit comments