From a28945273d99607b92eea1f05f57d7e1874fc20d Mon Sep 17 00:00:00 2001 From: syeopite Date: Fri, 3 Sep 2021 03:33:49 -0700 Subject: [PATCH] Propagate replacing yout.be links to /watch to RSS --- src/invidious/comments.cr | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/invidious/comments.cr b/src/invidious/comments.cr index 6dc27639..5f607524 100644 --- a/src/invidious/comments.cr +++ b/src/invidious/comments.cr @@ -481,11 +481,15 @@ def replace_links(html) url = URI.parse(anchor["href"]) if {"www.youtube.com", "m.youtube.com", "youtu.be"}.includes?(url.host) - if url.path == "/redirect" - params = HTTP::Params.parse(url.query.not_nil!) - anchor["href"] = params["q"]? + if url.host == "youtu.be" + url = "/watch?v=#{url.request_target.lstrip('/')}" else - anchor["href"] = url.request_target + if url.path == "/redirect" + params = HTTP::Params.parse(url.query.not_nil!) + anchor["href"] = params["q"]? + else + anchor["href"] = url.request_target + end end elsif url.to_s == "#" begin