Add workaround for youtu.be links in comments

This commit is contained in:
syeopite 2021-08-30 20:42:26 -07:00
parent 4fcd0964cd
commit a97e2cbe27
No known key found for this signature in database
GPG Key ID: 6FA616E5A5294A82

View File

@ -552,7 +552,10 @@ def content_to_comment_html(content)
if url = run["navigationEndpoint"]["urlEndpoint"]?.try &.["url"].as_s
url = URI.parse(url)
if !url.host || {"m.youtube.com", "www.youtube.com", "youtu.be"}.includes? url.host
if !url.host
elsif url.host == "youtu.be"
url = "/watch?v=#{url.request_target.lstrip('/')}"
elsif {"m.youtube.com", "www.youtube.com"}.includes? url
if url.path == "/redirect"
url = HTTP::Params.parse(url.query.not_nil!)["q"]
else