summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamantaz Fox <coding@samantaz.fr>2023-09-16 00:54:14 +0200
committerSamantaz Fox <coding@samantaz.fr>2023-09-16 00:54:14 +0200
commitebee973b2454f3e1adfab798ed8be6b9ef123069 (patch)
treefc2729ab203ed784be124be3cec4e8b8d5a566b4
parent2425c47882feaa56a69f6ba842cf1cb9d5b450e0 (diff)
downloadinvidious-ebee973b2454f3e1adfab798ed8be6b9ef123069.tar.gz
invidious-ebee973b2454f3e1adfab798ed8be6b9ef123069.tar.bz2
invidious-ebee973b2454f3e1adfab798ed8be6b9ef123069.zip
Routes: Redirect unknown channel tabs to channel home page
-rw-r--r--src/invidious/routes/channels.cr6
-rw-r--r--src/invidious/routing.cr2
2 files changed, 7 insertions, 1 deletions
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