Issue: When one of the affected area codes is used to populate a phone number and user backspaces to remove digits, if the backspace would cause phone number length to be 7 digits, regex pattern causes the "national format" to output with the area code duplicated.
The metadata regex patterns for the affected countries may be at fault. Their country code is actually +1 (North America) and the "area code" is the following 3 digits. Regex pattern should probably use pattern length of 10 for these to allow for the "area code" to be part of the full phone number (similar to Canada, US, Dominican Republic etc). Our findings show the regex has length of 7. Making the adjustment manually in the metadata file did stop this from happening.
Issue: When one of the affected area codes is used to populate a phone number and user backspaces to remove digits, if the backspace would cause phone number length to be 7 digits, regex pattern causes the "national format" to output with the area code duplicated.
The metadata regex patterns for the affected countries may be at fault. Their country code is actually +1 (North America) and the "area code" is the following 3 digits. Regex pattern should probably use pattern length of 10 for these to allow for the "area code" to be part of the full phone number (similar to Canada, US, Dominican Republic etc). Our findings show the regex has length of 7. Making the adjustment manually in the metadata file did stop this from happening.
Here's an example for American Samoa using appspot https://libphonenumber.appspot.com/phonenumberparser?number=6845551&country=AS![image](https://github.com/catamphetamine/libphonenumber-js/assets/141076862/ad5ec500-247c-4fa5-8e72-221a930ebb74)
The metadata file has this entry for American Samoa:
"AS":["1","011","(?:[58]\\d\\d|684|900)\\d{7}",[10],0,"1",0,"([267]\\d{6})$|1","684$1",0,"684"]
The regex pattern we tested changing was
([267]\\d{6})$|1
which we changed to([267]\\d{9})$|1
and the problem did not occur againFull list of affected dialing codes / countries: