Use “www.youtube.com” consistently (#5768)

Saves an unnecessary redirect by using `www.youtube.com` on some parts of Invidious where `youtube.com` was used instead. youtube.com will redirect to www.youtube.com anyways.

Co-authored-by: janmoesen <@>
This commit is contained in:
Jan Moesen
2026-06-09 22:25:27 +02:00
committed by GitHub
parent 067260a4ab
commit 6dec63a3e5
4 changed files with 5 additions and 5 deletions

View File

@@ -201,7 +201,7 @@ def error_redirect_helper(env : HTTP::Server::Context)
<a href="/redirect?referer=#{env.get("current_page")}">#{switch_instance}</a> <a href="/redirect?referer=#{env.get("current_page")}">#{switch_instance}</a>
</li> </li>
<li> <li>
<a rel="noreferrer noopener" href="https://youtube.com#{env.request.resource}">#{go_to_youtube}</a> <a rel="noreferrer noopener" href="https://www.youtube.com#{env.request.resource}">#{go_to_youtube}</a>
</li> </li>
</ul> </ul>
END_HTML END_HTML

View File

@@ -351,7 +351,7 @@ module Invidious::Routes::Channels
invidious_url_params.delete_all("user") invidious_url_params.delete_all("user")
begin begin
resolved_url = YoutubeAPI.resolve_url("https://youtube.com#{env.request.path}#{yt_url_params.size > 0 ? "?#{yt_url_params}" : ""}") resolved_url = YoutubeAPI.resolve_url("https://www.youtube.com#{env.request.path}#{yt_url_params.size > 0 ? "?#{yt_url_params}" : ""}")
ucid = resolved_url["endpoint"]["browseEndpoint"]["browseId"] ucid = resolved_url["endpoint"]["browseEndpoint"]["browseId"]
rescue ex : InfoException | KeyError rescue ex : InfoException | KeyError
return error_template(404, I18n.translate(locale, "This channel does not exist.")) return error_template(404, I18n.translate(locale, "This channel does not exist."))

View File

@@ -8,7 +8,7 @@ module Invidious::Routes::ErrorRoutes
if md = env.request.path.match(/^\/(?<id>([a-zA-Z0-9_-]{11})|(\w+))$/) if md = env.request.path.match(/^\/(?<id>([a-zA-Z0-9_-]{11})|(\w+))$/)
item = md["id"] item = md["id"]
# Check if item is branding URL e.g. https://youtube.com/gaming # Check if item is branding URL e.g. https://www.youtube.com/gaming
response = YT_POOL.client &.get("/#{item}") response = YT_POOL.client &.get("/#{item}")
if response.status_code == 301 if response.status_code == 301

View File

@@ -480,7 +480,7 @@ module YoutubeAPI
# #
# ``` # ```
# # Valid channel "brand URL" gives the related UCID and browse ID # # Valid channel "brand URL" gives the related UCID and browse ID
# channel_a = YoutubeAPI.resolve_url("https://youtube.com/c/google") # channel_a = YoutubeAPI.resolve_url("https://www.youtube.com/c/google")
# channel_a # => { # channel_a # => {
# "endpoint": { # "endpoint": {
# "browseEndpoint": { # "browseEndpoint": {
@@ -492,7 +492,7 @@ module YoutubeAPI
# } # }
# #
# # Invalid URL returns throws an InfoException # # Invalid URL returns throws an InfoException
# channel_b = YoutubeAPI.resolve_url("https://youtube.com/c/invalid") # channel_b = YoutubeAPI.resolve_url("https://www.youtube.com/c/invalid")
# ``` # ```
# #
def resolve_url(url : String, client_config : ClientConfig | Nil = nil) def resolve_url(url : String, client_config : ClientConfig | Nil = nil)