From 08435a39215eecdb6d66b2b037b76b0ce71b8b95 Mon Sep 17 00:00:00 2001 From: Jon Banafato Date: Fri, 18 Nov 2022 14:56:09 -0500 Subject: [PATCH] Support handle URLs for YouTube detection YouTube recently added support for handles and has updated some links in the UI to default to these formats. The existing logic works without modification once a new regex for matching against handle URLs is added. --- rsspreview.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rsspreview.js b/rsspreview.js index 4709f5f..b4a09bd 100644 --- a/rsspreview.js +++ b/rsspreview.js @@ -388,11 +388,13 @@ function findYouTubeFeeds() { // YouTube's canonical channel URLs look like /channel/AlphaNumericID // It also supports named channels of the form /c/MyChannelName + // and handle links of the form /@MyChannelHandle. // Match also on '%' to handle non-latin character codes // Match on both of these to autodetect channel feeds on either URL let idPattern = /channel\/([a-zA-Z0-9%_-]+)/; let namePattern = /(?:c|user)\/[a-zA-Z0-9%_-]+/; - let urlPattern = new RegExp(`${idPattern.source}|${namePattern.source}`); + let handlePattern = /@[a-zA-Z0-9%_-]+/; + let urlPattern = new RegExp(`${idPattern.source}|${namePattern.source}|${handlePattern.source}`); if (document.URL.match(urlPattern)) { let feeds = {}; let canonicalUrl = document.querySelector("link[rel='canonical']").href;