File tree Expand file tree Collapse file tree 2 files changed +11
-0
lines changed
Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,12 @@ describe('parseFmtpParams', () => {
2727 expect ( Object . fromEntries ( fmtpParams ) ) . toStrictEqual ( { '0-5' : undefined } ) ; // firefox RED
2828 fmtpParams = parseFmtpParams ( 'a=fmtp:100 0-15,66,70' ) ;
2929 expect ( Object . fromEntries ( fmtpParams ) ) . toStrictEqual ( { '0-15,66,70' : undefined } ) ; // telephone event
30+ fmtpParams = parseFmtpParams ( 'a=fmtp:45 profile=0;level-idx=19;tier=0;' ) ;
31+ expect ( Object . fromEntries ( fmtpParams ) ) . toStrictEqual ( {
32+ 'level-idx' : '19' ,
33+ profile : '0' ,
34+ tier : '0' ,
35+ } ) ; // semicolon at the end case
3036 } ) ;
3137 it ( 'exceptional case' , async ( ) => {
3238 expect . hasAssertions ( ) ;
Original file line number Diff line number Diff line change @@ -37,8 +37,13 @@ export function parseFmtpParams(fmtpParams: string) {
3737 return fmtpObj ;
3838 }
3939
40+ // Trim any trailing semicolons
41+ // eslint-disable-next-line no-param-reassign
42+ fmtpParams = fmtpParams . replace ( / ; $ / , '' ) ;
43+
4044 fmtpParams . split ( ';' ) . forEach ( ( param ) => {
4145 const paramArr = param && param . split ( '=' ) ;
46+
4247 if ( paramArr . length !== 2 || ! paramArr [ 0 ] || ! paramArr [ 1 ] ) {
4348 throw new Error ( `Fmtp params is invalid with ${ fmtpParams } ` ) ;
4449 }
You can’t perform that action at this time.
0 commit comments