Skip to content

Handle more scenarios #4

Closed
Closed
@larsfriis-io

Description

@larsfriis-io

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);
}
}

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions