From 318026895b8dace61629f1b8ce2a52245bc581e4 Mon Sep 17 00:00:00 2001 From: Bill Date: Mon, 20 Apr 2020 11:54:41 -0400 Subject: [PATCH] Account for addtional query parameters when parsing video ID (#75) * Account for extra query parameters when parsing video ID * Use URL module to parse URL --- src/destreamer.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/destreamer.ts b/src/destreamer.ts index c8f8b04..f1a9e1c 100644 --- a/src/destreamer.ts +++ b/src/destreamer.ts @@ -105,10 +105,10 @@ function extractVideoGuid(videoUrls: string[]): string[] { for (const url of videoUrls) { try { - guid = url.split('/').pop(); - + const urlObj = new URL(url); + guid = urlObj.pathname.split('/').pop(); } catch (e) { - console.error(`${e.message}`); + console.error(`Unrecognized URL format in ${url}: ${e.message}`); process.exit(ERROR_CODE.INVALID_VIDEO_GUID); }