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
6 changes: 6 additions & 0 deletions src/lines/fmtp-line.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ describe('parseFmtpParams', () => {
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
fmtpParams = parseFmtpParams('a=fmtp:45 profile=0;level-idx=19;tier=0;');
expect(Object.fromEntries(fmtpParams)).toStrictEqual({
'level-idx': '19',
profile: '0',
tier: '0',
}); // semicolon at the end case
});
it('exceptional case', async () => {
expect.hasAssertions();
Expand Down
5 changes: 5 additions & 0 deletions src/lines/fmtp-line.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,13 @@ export function parseFmtpParams(fmtpParams: string) {
return fmtpObj;
}

// Trailing semicolons are not technically allowed, but we've seen some occurrences and don't want to choke on them, so strip them here
// eslint-disable-next-line no-param-reassign
fmtpParams = fmtpParams.replace(/;$/, '');

fmtpParams.split(';').forEach((param) => {
const paramArr = param && param.split('=');

if (paramArr.length !== 2 || !paramArr[0] || !paramArr[1]) {
throw new Error(`Fmtp params is invalid with ${fmtpParams}`);
}
Expand Down