Skip to content

Commit 1e61961

Browse files
[BugFix BetaBlocking] Fix PSTN start Call (#2739)
* update parsing function to handle phone numbers * add test for E.164 formatting * Change files * Duplicate change files for beta release
1 parent 5be21c4 commit 1e61961

4 files changed

Lines changed: 26 additions & 1 deletion

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "prerelease",
3+
"comment": "Fix PSTN id parsing and add unit test to validate E.164 format numbers.",
4+
"packageName": "@azure/communication-react",
5+
"email": "94866715+dmceachernmsft@users.noreply.github.com",
6+
"dependentChangeType": "patch"
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "prerelease",
3+
"comment": "Fix PSTN id parsing and add unit test to validate E.164 format numbers.",
4+
"packageName": "@azure/communication-react",
5+
"email": "94866715+dmceachernmsft@users.noreply.github.com",
6+
"dependentChangeType": "patch"
7+
}

packages/acs-ui-common/src/identifier.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@ test('Communication user conversions', () => {
1919
expect(toFlatCommunicationIdentifier(parsed)).toEqual('8:acs:OPAQUE');
2020
});
2121

22+
test('phone number conversion from E.164 format', () => {
23+
const parsed = fromFlatCommunicationIdentifier('+15555555555');
24+
expect(isPhoneNumberIdentifier(parsed)).toBeTruthy;
25+
expect(parsed).toEqual({
26+
kind: 'phoneNumber',
27+
phoneNumber: '15555555555'
28+
});
29+
});
30+
2231
test('Phone number conversions', () => {
2332
const parsed = fromFlatCommunicationIdentifier('4:OPAQUE');
2433
expect(isPhoneNumberIdentifier(parsed)).toBeTruthy();

packages/acs-ui-common/src/identifier.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ export const toFlatCommunicationIdentifier = (identifier: CommunicationIdentifie
2323
* @public
2424
*/
2525
export const fromFlatCommunicationIdentifier = (id: string): CommunicationIdentifier => {
26-
return createIdentifierFromRawId(id);
26+
// if the id passed is a phone number we need to build the rawId to pass in
27+
const rawId = id.indexOf('+') === 0 ? '4:' + id.slice(1) : id;
28+
return createIdentifierFromRawId(rawId);
2729
};
2830

2931
/**

0 commit comments

Comments
 (0)