Skip to content
This repository has been archived by the owner on Aug 17, 2023. It is now read-only.

Commit

Permalink
feat: allow parsing of dial-codes as phone number in active-calls
Browse files Browse the repository at this point in the history
  • Loading branch information
adroste committed Dec 29, 2021
1 parent 4af2f0d commit 5332738
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 7 deletions.
4 changes: 2 additions & 2 deletions build/src/func/active-calls.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build/src/func/active-calls.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions build/src/func/active-calls.test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build/src/func/active-calls.test.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions src/func/active-calls.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ describe('active-calls callerId parsing', () => {
expect(info.phoneNumber).toBe('10');
expect(info.displayName).toBe('My Fav Nr Is 55');
});

it('should parse dial code numbers: 10001 Service A - 11 (*91234)', () => {
const info = createCallerInfoFromCallerId('10001 Service A - 11 (*91234)');
expect(info.phoneNumber).toBe('*91234');
expect(info.displayName).toBe('10001 Service A - 11');
});
});

afterAll(async () => {
Expand Down
6 changes: 3 additions & 3 deletions src/func/active-calls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ export interface ActiveCall {
}

function getPhoneNumberFromCallerId(callerId: string) {
// format can be for instance: "Name name (+123456789)", "(123495)", "+4359090132", "1234 Name name"
// format can be for instance: "Name name (+123456789)", "(123495)", "+4359090132", "1234 Name name", "*91234"
// minimum 2 digits as 3CX extensions/dns can have 2,3 or 4 numbers
const test1 = /\(([+]?\d{2,})\)$/; // check for number in parenthesis
const test2 = /^([+]?\d{2,})/; // check for number at the beginning
const test1 = /\(([+*]?\d{2,})\)$/; // check for number in parenthesis
const test2 = /^([+*]?\d{2,})/; // check for number at the beginning
const match1 = test1.exec(callerId);
const match2 = test2.exec(callerId);
// match in parenthesis has priority
Expand Down

0 comments on commit 5332738

Please sign in to comment.