Skip to content

Commit

Permalink
Properly transform youtu.be links to be /watch routes in comments and…
Browse files Browse the repository at this point in the history
… descriptions (iv-org#2365)
  • Loading branch information
syeopite authored Sep 1, 2021
1 parent f938aa5 commit a1001ad
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/invidious/comments.cr
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,9 @@ 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 == "youtu.be"
url = "/watch?v=#{url.request_target.lstrip('/')}"
elsif !url.host || {"m.youtube.com", "www.youtube.com"}.includes? url
if url.path == "/redirect"
url = HTTP::Params.parse(url.query.not_nil!)["q"]
else
Expand Down

0 comments on commit a1001ad

Please sign in to comment.