Skip to content

Handle more scenarios #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
larsfriis-io opened this issue May 1, 2025 · 2 comments
Closed

Handle more scenarios #4

larsfriis-io opened this issue May 1, 2025 · 2 comments
Assignees

Comments

@larsfriis-io
Copy link

larsfriis-io commented May 1, 2025

Hi

Please see these updated line of code so we can handle these two new cases:

  • Numbers that start with areacode + space + number : ex: "45 30270000"
  • Swedish numbers starting with 0, which is a signal, that no areacode is added: 073027000 becomes +4673027000 because the first 0 is removed

` // Clean up area code from the phone number if present
if (phone.indexOf('+' + areaCode) === 0) {
phone = phone.substring(areaCode.length + 1);
} else if (phone.indexOf('00' + areaCode) === 0) {
phone = phone.substring(areaCode.length + 2);
} else if (phone.indexOf(areaCode + ' ') === 0) { // handle country code + space (ex: "45 30270000")
phone = phone.substring(areaCode.length + 1);
}
// Handle Swedish phone number starting with 0 (but not 0046)
if (countryCode === 'se') {
if (phone.indexOf('0') === 0 && phone.substring(0, 4) !== '0046') {
phone = phone.substring(1);
}
}

@giovaniortolani
Copy link
Contributor

giovaniortolani commented May 2, 2025

Replied on Slack.

All except the Swedish national phone number support is already covered.

@giovaniortolani
Copy link
Contributor

The Swedish national phone number support is part of #5 and stape-io/phone-number-formatter-variable#2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants