summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/invidious/comments.cr8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/invidious/comments.cr b/src/invidious/comments.cr
index 5f607524..57fba565 100644
--- a/src/invidious/comments.cr
+++ b/src/invidious/comments.cr
@@ -480,9 +480,9 @@ def replace_links(html)
html.xpath_nodes(%q(//a)).each do |anchor|
url = URI.parse(anchor["href"])
- if {"www.youtube.com", "m.youtube.com", "youtu.be"}.includes?(url.host)
- if url.host == "youtu.be"
- url = "/watch?v=#{url.request_target.lstrip('/')}"
+ if url.host.nil? || url.host.not_nil!.ends_with?("youtube.com") || url.host.not_nil!.ends_with?("youtu.be")
+ if url.host.try &.ends_with? "youtu.be"
+ url = "/watch?v=#{url.path.lstrip('/')}#{url.query_params}"
else
if url.path == "/redirect"
params = HTTP::Params.parse(url.query.not_nil!)
@@ -558,7 +558,7 @@ def content_to_comment_html(content)
if url.host == "youtu.be"
url = "/watch?v=#{url.request_target.lstrip('/')}"
- elsif !url.host || {"m.youtube.com", "www.youtube.com"}.includes? url.host
+ elsif url.host.nil? || url.host.not_nil!.ends_with?("youtube.com")
if url.path == "/redirect"
url = HTTP::Params.parse(url.query.not_nil!)["q"]
else