From 3df861696ce06fa9a1cfe8634c8236ccfcd8f6a9 Mon Sep 17 00:00:00 2001 From: Cameron Radmore Date: Mon, 2 Nov 2026 23:58:44 -0500 Subject: [PATCH] feat: Adds support for custom channel handle urls with tab paths (ex: `{INSTANCE}/markrober/streams`) (#5811) * feat: add support for additional channel urls (:user/:tab) * fix: check known_tabs against downcased selected_tab * rebase, remove whitespace and move route to the correct place --------- Co-authored-by: Fijxu --- src/invidious/routes/channels.cr | 13 ++++++++++++- src/invidious/routing.cr | 3 +++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/invidious/routes/channels.cr b/src/invidious/routes/channels.cr index 9e3ac30d7..e3b8367fa 100644 --- a/src/invidious/routes/channels.cr +++ b/src/invidious/routes/channels.cr @@ -359,6 +359,17 @@ module Invidious::Routes::Channels "posts", } + def self.potential_brand_redirect(env) + # Check for known tab in url before trying to brand_redirect (avoids unneeded request to YouTube) + selected_tab = env.params.url["tab"]?.try &.downcase + + if KNOWN_TABS.includes? selected_tab + brand_redirect(env) + else + Invidious::Routes::Misc.home(env) + end + end + # Redirects brand url channels to a normal /channel/:ucid route def self.brand_redirect(env) locale = env.get("preferences").as(Preferences).locale @@ -381,7 +392,7 @@ module Invidious::Routes::Channels return Errors.error_template(404, I18n.translate(locale, "This channel does not exist.")) end - selected_tab = env.params.url["tab"]? + selected_tab = env.params.url["tab"]?.try &.downcase if KNOWN_TABS.includes? selected_tab url = "/channel/#{ucid}/#{selected_tab}" diff --git a/src/invidious/routing.cr b/src/invidious/routing.cr index d84e99026..cdcbfdf29 100644 --- a/src/invidious/routing.cr +++ b/src/invidious/routing.cr @@ -146,6 +146,9 @@ module Invidious::Routing get "/user/:user", Routes::Channels, :brand_redirect get "/user/:user/:tab", Routes::Channels, :brand_redirect + # /linuxtechtips/streams + get "/:user/:tab", Routes::Channels, :potential_brand_redirect + # /@LinusTechTips (Handle) get "/@:user", Routes::Channels, :brand_redirect get "/@:user/:tab", Routes::Channels, :brand_redirect