From 6f4fbdba50e551c026927ae8f1584556c3c7767c Mon Sep 17 00:00:00 2001 From: Bryce Tham Date: Tue, 12 Dec 2023 12:56:46 -0500 Subject: [PATCH] fix: handle invalid m-line with trailing whitespace (#67) Co-authored-by: Bryce Tham --- src/peer-connection.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/peer-connection.ts b/src/peer-connection.ts index 4ec0d98..f3b36ff 100644 --- a/src/peer-connection.ts +++ b/src/peer-connection.ts @@ -209,7 +209,7 @@ class PeerConnection extends EventEmitter { ?.split(/(\r\n|\r|\n)/) .filter((line) => line.startsWith('m')) .forEach((mediaLine) => { - if (mediaLine.split(' ').length < 4) { + if (mediaLine.trim().split(' ').length < 4) { throw new Error(`Invalid media line ${mediaLine}, expected at least 4 fields`); } });