1
0
mirror of https://github.com/aureliendavid/rsspreview.git synced 2025-08-22 19:28:39 +00:00

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.
This commit is contained in:
Jon Banafato 2022-11-18 14:56:09 -05:00
parent 0f3d18390b
commit 08435a3921

View File

@ -388,11 +388,13 @@
function findYouTubeFeeds() { function findYouTubeFeeds() {
// YouTube's canonical channel URLs look like /channel/AlphaNumericID // YouTube's canonical channel URLs look like /channel/AlphaNumericID
// It also supports named channels of the form /c/MyChannelName // 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 also on '%' to handle non-latin character codes
// Match on both of these to autodetect channel feeds on either URL // Match on both of these to autodetect channel feeds on either URL
let idPattern = /channel\/([a-zA-Z0-9%_-]+)/; let idPattern = /channel\/([a-zA-Z0-9%_-]+)/;
let namePattern = /(?:c|user)\/[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)) { if (document.URL.match(urlPattern)) {
let feeds = {}; let feeds = {};
let canonicalUrl = document.querySelector("link[rel='canonical']").href; let canonicalUrl = document.querySelector("link[rel='canonical']").href;