fix regex for matching urls with - in id

This commit is contained in:
simon 2022-06-17 16:47:40 +07:00
parent fb642282a9
commit 7007a920c1
No known key found for this signature in database
GPG Key ID: 2C15AA5E89985DD4

View File

@ -24,11 +24,11 @@ function getBrowser() {
function detectUrlType(url) { 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)) { if (videoRe.test(url)) {
return "video" 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)) { if (channelRe.test(url)) {
return "channel" return "channel"
} }