diff --git a/src/invidious/helpers/utils.cr b/src/invidious/helpers/utils.cr index 7a262f849..f0efa245f 100644 --- a/src/invidious/helpers/utils.cr +++ b/src/invidious/helpers/utils.cr @@ -386,6 +386,18 @@ def parse_link_endpoint(endpoint : JSON::Any, text : String, video_id : String) return text end +def linkify_hashtags(title : String) : String + String.build do |str| + pos = 0 + title.scan(/#([a-zA-Z0-9_]+)/) do |match| + str << title[pos...match.begin(0)] + str << %(#{match[0]}) + pos = match.end(0) + end + str << title[pos..] + end +end + def encrypt_ecb_without_salt(data, key) cipher = OpenSSL::Cipher.new("aes-128-ecb") cipher.encrypt diff --git a/src/invidious/views/watch.ecr b/src/invidious/views/watch.ecr index 3dc19c9e2..266065fbc 100644 --- a/src/invidious/views/watch.ecr +++ b/src/invidious/views/watch.ecr @@ -93,7 +93,11 @@ we're going to need to do it here in order to allow for translations.

- <%= title %> + <% if video.title.matches?(/#\w/) %> + <%= linkify_hashtags(title) %> + <% else %> + <%= title %> + <% end %> <% if params.listen %> " id="link-iv-listen" data-base-url="/watch?<%= env.params.query %>&listen=0" href="/watch?<%= env.params.query %>&listen=0">