mirror of
https://github.com/iv-org/invidious.git
synced 2026-11-04 02:47:15 +00:00
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 <fijxu@nadeko.net>
This commit is contained in:
@@ -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}"
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user