From 298af854fc87ccf2951258aceeda22ae08c598c4 Mon Sep 17 00:00:00 2001 From: Omar Roth Date: Fri, 9 Mar 2018 14:06:35 -0600 Subject: [PATCH] Fix alt_link for youtu.be --- src/helpers.cr | 14 +++++++++++--- 1 file 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 END_HTML - - alt_links << {match.end.not_nil!, alt_link} + elsif url.host == "youtu.be" + alt_link = <<-END_HTML + + + + END_HTML + else + alt_link = "" end + + alt_links << {match.end.not_nil!, alt_link} end alt_links.reverse!