From 7ad5e426fb965d4a06575377704244bd3c4dd2f3 Mon Sep 17 00:00:00 2001 From: Official Noob <31563761+OfficialNoob@users.noreply.github.com> Date: Tue, 6 Aug 2019 10:27:13 +0100 Subject: [PATCH] Improved Parser --- utils.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/utils.js b/utils.js index 1e4da828..c12fb6cb 100644 --- a/utils.js +++ b/utils.js @@ -2,12 +2,10 @@ function getYouTubeVideoID(url) { // Returns with video id else returns false var regExp = /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/; var match = url.match(regExp); var id = new URL(url).searchParams.get("v"); - if (url.includes("/embed/")) { - //it is an embed, don't search for v + if (url.includes("/embed/")) { //it is an embed, don't search for v id = match[7]; } - - return (match && match[7].length == 11) ? id : false; + return (match) ? id : false; } //returns the start time of the video if there was one specified (ex. ?t=5s)