diff options
| author | Omar Roth <omarroth@hotmail.com> | 2018-03-09 14:06:35 -0600 |
|---|---|---|
| committer | Omar Roth <omarroth@hotmail.com> | 2018-03-09 14:06:35 -0600 |
| commit | 298af854fc87ccf2951258aceeda22ae08c598c4 (patch) | |
| tree | 26b7fa60d5928478ab858524058ac8213bc1c86b | |
| parent | c6accd27064e57fce0d2d34d15924a1c60fc7b24 (diff) | |
| download | invidious-298af854fc87ccf2951258aceeda22ae08c598c4.tar.gz invidious-298af854fc87ccf2951258aceeda22ae08c598c4.tar.bz2 invidious-298af854fc87ccf2951258aceeda22ae08c598c4.zip | |
Fix alt_link for youtu.be
| -rw-r--r-- | src/helpers.cr | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/helpers.cr b/src/helpers.cr index bbcc07d6..784306c2 100644 --- a/src/helpers.cr +++ b/src/helpers.cr @@ -366,15 +366,23 @@ def add_alt_links(html) anchor = anchor.xpath_node("//a").not_nil! url = URI.parse(HTML.unescape(anchor["href"])) - if ["www.youtube.com", "m.youtube.com"].includes?(url.host) && url.path == "/watch" || url.host == "youtu.be" + if ["www.youtube.com", "m.youtube.com"].includes?(url.host) && url.path == "/watch" alt_link = <<-END_HTML <a href="#{url.full_path}"> <i class="fa fa-link" aria-hidden="true"></i> </a> END_HTML - - alt_links << {match.end.not_nil!, alt_link} + elsif url.host == "youtu.be" + alt_link = <<-END_HTML + <a href="/watch?v=#{url.full_path.lchop("/")}"> + <i class="fa fa-link" aria-hidden="true"></i> + </a> + END_HTML + else + alt_link = "" end + + alt_links << {match.end.not_nil!, alt_link} end alt_links.reverse! |
