diff options
| author | Samantaz Fox <coding@samantaz.fr> | 2021-03-11 00:42:13 +0000 |
|---|---|---|
| committer | Samantaz Fox <coding@samantaz.fr> | 2021-03-11 00:42:13 +0000 |
| commit | 57ea45ff51f30b219a2902d441012471795f0265 (patch) | |
| tree | 27e49a0bc01e895789bf777855fef13d14d60d9d | |
| parent | ec30f7c5d4c1168a68b683d9805fb3db2fd2da4b (diff) | |
| download | invidious-57ea45ff51f30b219a2902d441012471795f0265.tar.gz invidious-57ea45ff51f30b219a2902d441012471795f0265.tar.bz2 invidious-57ea45ff51f30b219a2902d441012471795f0265.zip | |
content_to_comment_html: Fix /watch links + make newline replace universal
| -rw-r--r-- | src/invidious/comments.cr | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/invidious/comments.cr b/src/invidious/comments.cr index 13ebbd73..20e64a08 100644 --- a/src/invidious/comments.cr +++ b/src/invidious/comments.cr @@ -488,8 +488,12 @@ def replace_links(html) length_seconds = decode_time(anchor.content) end - anchor["href"] = "javascript:void(0)" - anchor["onclick"] = "player.currentTime(#{length_seconds})" + if length_seconds > 0 + anchor["href"] = "javascript:void(0)" + anchor["onclick"] = "player.currentTime(#{length_seconds})" + else + anchor["href"] = url.request_target + end end end @@ -528,11 +532,7 @@ end def content_to_comment_html(content) comment_html = content.map do |run| - text = HTML.escape(run["text"].as_s) - - if run["text"] == "\n" - text = "<br>" - end + text = HTML.escape(run["text"].as_s).gsub("\n", "<br>") if run["bold"]? text = "<b>#{text}</b>" @@ -559,7 +559,7 @@ def content_to_comment_html(content) length_seconds = watch_endpoint["startTimeSeconds"]? video_id = watch_endpoint["videoId"].as_s - if length_seconds + if length_seconds && length_seconds.as_i > 0 text = %(<a href="javascript:void(0)" data-onclick="jump_to_time" data-jump-time="#{length_seconds}">#{text}</a>) else text = %(<a href="/watch?v=#{video_id}">#{text}</a>) |
