Skip to content

Commit

Permalink
fix: allow comma special case in fmtp line (#17)
Browse files Browse the repository at this point in the history
* fix: allow comma special case in fmtp line

* chore: reference telephone event spec

---------

Co-authored-by: Bryce Tham <btham@cisco.com>
  • Loading branch information
brycetham and Bryce Tham committed Jun 26, 2023
1 parent 06404d2 commit a11b9a2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/lines/fmtp-line.spec.ts
Expand Up @@ -19,6 +19,15 @@ describe('parseFmtpParams', () => {
);
expect(Object.fromEntries(fmtpParams)).toStrictEqual(expectedValue);
});
it('special case', async () => {
expect.hasAssertions();
let fmtpParams = parseFmtpParams('a=fmtp:121 0/5');
expect(Object.fromEntries(fmtpParams)).toStrictEqual({ '0/5': undefined }); // chrome RED
fmtpParams = parseFmtpParams('a=fmtp:121 0-5');
expect(Object.fromEntries(fmtpParams)).toStrictEqual({ '0-5': undefined }); // firefox RED
fmtpParams = parseFmtpParams('a=fmtp:100 0-15,66,70');
expect(Object.fromEntries(fmtpParams)).toStrictEqual({ '0-15,66,70': undefined }); // telephone event
});
it('exceptional case', async () => {
expect.hasAssertions();
expect(() => {
Expand Down
3 changes: 2 additions & 1 deletion src/lines/fmtp-line.ts
Expand Up @@ -31,7 +31,8 @@ export function parseFmtpParams(fmtpParams: string) {
const fmtpObj = new Map<string, string | undefined>();

// compatible with RED,such as `a=fmtp:121 0/5` in chrome and `a=fmtp:121 0-5` in firefox, which can {@link https://www.rfc-editor.org/rfc/rfc2198}
if (/^\d+([/-]\d+)+$/.test(fmtpParams)) {
// also compatible with telephone event, such as `a=fmtp:100 0-15,66,70`, see {@link https://www.rfc-editor.org/rfc/rfc4733.html#section-2.4.1}
if (/^\d+([,/-]\d+)+$/.test(fmtpParams)) {
fmtpObj.set(fmtpParams, undefined);
return fmtpObj;
}
Expand Down

0 comments on commit a11b9a2

Please sign in to comment.