Skip to content

Commit 9748088

Browse files
committed
fix: handle 010 area codes when formatting se phone numbers
1 parent b346fa9 commit 9748088

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

.changeset/fifty-ads-jump.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
"@obosbbl/format": patch
3+
---
4+
5+
fix formatting of Swedish phone numbers that start with the area code 010
6+
7+
Previously it didn't recognize 010 as a 3 digit area code, so the format would be wrong.
8+
9+
```js
10+
// before
11+
formatPhoneNumber('010-1234567'); // -> 0101-23 45 67
12+
// after
13+
formatPhoneNumber('010-1234567'); // -> 010-123 45 67
14+
```

packages/format/src/format.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ describe('se', () => {
5050
['081234567', '08-123 45 67'],
5151
['0812345678', '08-123 456 78'],
5252
// 3 digit area code
53+
['010-123 45 67', '010-123 45 67'],
5354
['03112345', '031-123 45'],
5455
['031123456', '031-12 34 56'],
5556
['0311234567', '031-123 45 67'],

packages/format/src/se.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const SUBSCRIBER_NUMBER_FORMATS = {
1111
// SE numbers have area codes of 2, 3 or 4 digits
1212
const TWO_DIGIT_AREA_CODE = /^08/;
1313
const THREE_DIGIT_AREA_CODE =
14-
/^0(11|13|16|18|19|21|23|26|31|33|35|36|40|42|44|46|54|60|63|90)/;
14+
/^0(10|11|13|16|18|19|21|23|26|31|33|35|36|40|42|44|46|54|60|63|90)/;
1515

1616
/**
1717
* Format a phone number.

0 commit comments

Comments
 (0)