Routes: Redirect unknown channel tabs to channel home page

This commit is contained in:
Samantaz Fox 2023-09-16 00:54:14 +02:00
parent 2425c47882
commit ebee973b24
No known key found for this signature in database
GPG Key ID: F42821059186176E
2 changed files with 7 additions and 1 deletions

View File

@ -1,6 +1,12 @@
{% skip_file if flag?(:api_only) %} {% skip_file if flag?(:api_only) %}
module Invidious::Routes::Channels 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) def self.home(env)
self.videos(env) self.videos(env)
end end

View File

@ -131,7 +131,7 @@ module Invidious::Routing
# Channel catch-all, to redirect future routes to the channel's home # Channel catch-all, to redirect future routes to the channel's home
# NOTE: defined last in order to be processed after the other routes # 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 # /c/LinusTechTips
get "/c/:user", Routes::Channels, :brand_redirect get "/c/:user", Routes::Channels, :brand_redirect