From b964d93ea948b94515a7a93dc573c5ab5a52be3c Mon Sep 17 00:00:00 2001 From: Official Noob <31563761+OfficialNoob@users.noreply.github.com> Date: Wed, 7 Aug 2019 16:35:29 +0100 Subject: [PATCH] Update utils.js --- utils.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/utils.js b/utils.js index f7fb6ecf..80b4a1f3 100644 --- a/utils.js +++ b/utils.js @@ -11,11 +11,15 @@ function getYouTubeVideoID(url) { if (obj.pathname == "/watch" && obj.searchParams.has("v")) { id = obj.searchParams.get("v"); // Get ID from searchParam + return id.length == 11 ? id : false; } else if (obj.pathname.startsWith("/embed/")) { - id = obj.pathname.slice("/embed/".length); // Get ID from end or URL + try { + return obj.pathname.substr(7, 11); + } catch (e) { + console.error("[SB] Video ID not valid"); + return false + } } - - return id.length == 11 ? id : false; // If ID is not 11 in length return false } //returns the start time of the video if there was one specified (ex. ?t=5s)