From ebee973b2454f3e1adfab798ed8be6b9ef123069 Mon Sep 17 00:00:00 2001 From: Samantaz Fox Date: Sat, 16 Sep 2023 00:54:14 +0200 Subject: [PATCH] Routes: Redirect unknown channel tabs to channel home page --- src/invidious/routes/channels.cr | 6 ++++++ src/invidious/routing.cr | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/invidious/routes/channels.cr b/src/invidious/routes/channels.cr index 5500672f..d744712d 100644 --- a/src/invidious/routes/channels.cr +++ b/src/invidious/routes/channels.cr @@ -1,6 +1,12 @@ {% skip_file if flag?(:api_only) %} module Invidious::Routes::Channels + # Redirection for unsupported routes ("tabs") + def self.redirect_home(env) + ucid = env.params.url["ucid"] + return env.redirect "/channel/#{URI.encode_www_form(ucid)}" + end + def self.home(env) self.videos(env) end diff --git a/src/invidious/routing.cr b/src/invidious/routing.cr index f6b3aaa6..8c38aaed 100644 --- a/src/invidious/routing.cr +++ b/src/invidious/routing.cr @@ -131,7 +131,7 @@ module Invidious::Routing # Channel catch-all, to redirect future routes to the channel's home # NOTE: defined last in order to be processed after the other routes - get "/channel/:ucid/*", Routes::Channels, :home + get "/channel/:ucid/*", Routes::Channels, :redirect_home # /c/LinusTechTips get "/c/:user", Routes::Channels, :brand_redirect