Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Fix PSTN id parsing and add unit test to validate E.164 format numbers.",
"packageName": "@azure/communication-react",
"email": "94866715+dmceachernmsft@users.noreply.github.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Fix PSTN id parsing and add unit test to validate E.164 format numbers.",
"packageName": "@azure/communication-react",
"email": "94866715+dmceachernmsft@users.noreply.github.com",
"dependentChangeType": "patch"
}
9 changes: 9 additions & 0 deletions packages/acs-ui-common/src/identifier.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ test('Communication user conversions', () => {
expect(toFlatCommunicationIdentifier(parsed)).toEqual('8:acs:OPAQUE');
});

test('phone number conversion from E.164 format', () => {
const parsed = fromFlatCommunicationIdentifier('+15555555555');
expect(isPhoneNumberIdentifier(parsed)).toBeTruthy;
expect(parsed).toEqual({
kind: 'phoneNumber',
phoneNumber: '15555555555'
});
});

test('Phone number conversions', () => {
const parsed = fromFlatCommunicationIdentifier('4:OPAQUE');
expect(isPhoneNumberIdentifier(parsed)).toBeTruthy();
Expand Down
4 changes: 3 additions & 1 deletion packages/acs-ui-common/src/identifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ export const toFlatCommunicationIdentifier = (identifier: CommunicationIdentifie
* @public
*/
export const fromFlatCommunicationIdentifier = (id: string): CommunicationIdentifier => {
return createIdentifierFromRawId(id);
// if the id passed is a phone number we need to build the rawId to pass in
const rawId = id.indexOf('+') === 0 ? '4:' + id.slice(1) : id;
return createIdentifierFromRawId(rawId);
};

/**
Expand Down