From 954df15f42d9fe9358f48fa0747686e82f4b7875 Mon Sep 17 00:00:00 2001 From: Przemyslaw Pluta Date: Fri, 14 Feb 2014 08:51:22 +0000 Subject: [PATCH] Fix - Incorrect youtube video URL regex update and cleanup --- lib/youtube-dl.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/youtube-dl.js b/lib/youtube-dl.js index c8a3154..9a3b80d 100644 --- a/lib/youtube-dl.js +++ b/lib/youtube-dl.js @@ -23,7 +23,7 @@ fs.exists(file, function(exists) { var progressRegex = /(\d+(?:\.\d)?)% of (\d+\.\d+\w+) at\s+([^\s]+) ETA ((\d|-)+:(\d|-)+)/; -var isYouTubeRegex = /^(https?:\/\/www\.|https?:\/\/)?(youtube\.com|youtu\.be)\//; +var isYouTubeRegex = /^(https?:\/\/)?(www\.)?(youtube\.com|youtu\.be)\//; // check if win var isWin = /^win/.test(process.platform); @@ -52,10 +52,8 @@ exports.download = function(urladdr, dest, args) { // Get possible IDs. var id = query.v || ''; - // Check for youtube video url. - var isYouTube = isYouTubeRegex.test(urladdr); - - if (isYouTube && !id) { + // Check for long and short youtube video url. + if (!id && isYouTubeRegex.test(urladdr)) { // Get possible IDs for youtu.be from urladdr. id = details.pathname.slice(1); }