Skip to content

Commit 78c4478

Browse files
committed
Increase size of links displayed in video description
1 parent bf59928 commit 78c4478

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/invidious/comments.cr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -587,18 +587,18 @@ def content_to_comment_html(content)
587587
end
588588
end
589589

590-
text = %(<a href="#{url}">#{text}</a>)
590+
text = %(<a href="#{url}">#{reduce_uri(url)}</a>)
591591
elsif watch_endpoint = run["navigationEndpoint"]["watchEndpoint"]?
592592
length_seconds = watch_endpoint["startTimeSeconds"]?
593593
video_id = watch_endpoint["videoId"].as_s
594594

595595
if length_seconds && length_seconds.as_i > 0
596596
text = %(<a href="javascript:void(0)" data-onclick="jump_to_time" data-jump-time="#{length_seconds}">#{text}</a>)
597597
else
598-
text = %(<a href="/watch?v=#{video_id}">#{text}</a>)
598+
text = %(<a href="/watch?v=#{video_id}">#{reduce_uri("/watch?v=#{video_id}")}</a>)
599599
end
600600
elsif url = run.dig?("navigationEndpoint", "commandMetadata", "webCommandMetadata", "url").try &.as_s
601-
text = %(<a href="#{url}">#{text}</a>)
601+
text = %(<a href="#{url}">#{reduce_uri(url)}</a>)
602602
end
603603
end
604604

src/invidious/helpers/utils.cr

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,3 +365,14 @@ def fetch_random_instance
365365

366366
return filtered_instance_list.sample(1)[0]
367367
end
368+
369+
def reduce_uri(uri : URI | String, max_length : Int32? = 50, suffix : String? = "...") : String
370+
str = uri.to_s.sub(/https?:\/\//, "")
371+
if !max_length.nil? && str.size > max_length
372+
str = str[0, max_length]
373+
if !suffix.nil?
374+
str = "#{str}#{suffix}"
375+
end
376+
end
377+
return str
378+
end

0 commit comments

Comments
 (0)