From 6dec63a3e57c3f14ef6c615a96350d49a61a3d77 Mon Sep 17 00:00:00 2001
From: Jan Moesen <488144+janmoesen@users.noreply.github.com>
Date: Tue, 9 Jun 2026 22:25:27 +0200
Subject: [PATCH] =?UTF-8?q?Use=20=E2=80=9Cwww.youtube.com=E2=80=9D=20consi?=
=?UTF-8?q?stently=20(#5768)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
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 <@>
---
src/invidious/helpers/errors.cr | 2 +-
src/invidious/routes/channels.cr | 2 +-
src/invidious/routes/errors.cr | 2 +-
src/invidious/yt_backend/youtube_api.cr | 4 ++--
4 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/invidious/helpers/errors.cr b/src/invidious/helpers/errors.cr
index 97e28022..cee6eb2c 100644
--- a/src/invidious/helpers/errors.cr
+++ b/src/invidious/helpers/errors.cr
@@ -201,7 +201,7 @@ def error_redirect_helper(env : HTTP::Server::Context)
#{switch_instance}
- #{go_to_youtube}
+ #{go_to_youtube}
END_HTML
diff --git a/src/invidious/routes/channels.cr b/src/invidious/routes/channels.cr
index a9b476bc..0477802a 100644
--- a/src/invidious/routes/channels.cr
+++ b/src/invidious/routes/channels.cr
@@ -351,7 +351,7 @@ module Invidious::Routes::Channels
invidious_url_params.delete_all("user")
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"]
rescue ex : InfoException | KeyError
return error_template(404, I18n.translate(locale, "This channel does not exist."))
diff --git a/src/invidious/routes/errors.cr b/src/invidious/routes/errors.cr
index 1e9ab44e..e8e7e287 100644
--- a/src/invidious/routes/errors.cr
+++ b/src/invidious/routes/errors.cr
@@ -8,7 +8,7 @@ module Invidious::Routes::ErrorRoutes
if md = env.request.path.match(/^\/(?([a-zA-Z0-9_-]{11})|(\w+))$/)
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}")
if response.status_code == 301
diff --git a/src/invidious/yt_backend/youtube_api.cr b/src/invidious/yt_backend/youtube_api.cr
index dd709920..1783a542 100644
--- a/src/invidious/yt_backend/youtube_api.cr
+++ b/src/invidious/yt_backend/youtube_api.cr
@@ -480,7 +480,7 @@ module YoutubeAPI
#
# ```
# # 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 # => {
# "endpoint": {
# "browseEndpoint": {
@@ -492,7 +492,7 @@ module YoutubeAPI
# }
#
# # 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)