From 7007a920c1d4635b7971b8cf7b44f0172d802939 Mon Sep 17 00:00:00 2001 From: simon Date: Fri, 17 Jun 2022 16:47:40 +0700 Subject: [PATCH] fix regex for matching urls with - in id --- extension/script.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extension/script.js b/extension/script.js index caa6da3..97dbfc5 100644 --- a/extension/script.js +++ b/extension/script.js @@ -24,11 +24,11 @@ function getBrowser() { function detectUrlType(url) { - const videoRe = new RegExp(/^https:\/\/(www\.)?(youtube.com\/watch\?v=|youtu\.be\/)\w{11}/); + const videoRe = new RegExp(/^https:\/\/(www\.)?(youtube.com\/watch\?v=|youtu\.be\/)[\w-]{11}/); if (videoRe.test(url)) { return "video" } - const channelRe = new RegExp(/^https:?\/\/www\.?youtube.com\/c|channel|user\/\w+(\/|featured|videos)?$/); + const channelRe = new RegExp(/^https:?\/\/www\.?youtube.com\/c|channel|user\/[\w-]+(\/|featured|videos)?$/); if (channelRe.test(url)) { return "channel" }