From 50014697266f841e24c04a6cde32e25a2047ef30 Mon Sep 17 00:00:00 2001 From: Kelvin Nguyen Date: Thu, 2 Aug 2018 18:39:29 -0700 Subject: [PATCH] fix: Check null value for channelMatch within getAuthor from utils (#350) --- lib/util.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/util.js b/lib/util.js index adf3e37e..5996411b 100644 --- a/lib/util.js +++ b/lib/util.js @@ -371,7 +371,7 @@ exports.getVideoDescription = (html) => { /** * Get video media (extra information) from html - * + * * @param {String} body * @return {Object} */ @@ -416,13 +416,13 @@ exports.getAuthor = (body) => { const userMatch = ownerinfo.match(aliasRegexp); const verifiedMatch = ownerinfo.match(verifiedRegexp); return { - id: channelMatch[1], - name: channelMatch[2], + id: channelMatch ? channelMatch[1] : null, + name: channelMatch ? channelMatch[2] : null, avatar: url.resolve(VIDEO_URL, exports.between(ownerinfo, 'data-thumb="', '"')), verified: !!verifiedMatch && !!verifiedMatch[1], user: userMatch ? userMatch[1] : null, - channel_url: 'https://www.youtube.com/channel/' + channelMatch[1], + channel_url: channelMatch ? 'https://www.youtube.com/channel/' + channelMatch[1] : null, user_url: userMatch ? 'https://www.youtube.com/user/' + userMatch[1] : null, }; };