Increase size of links displayed in video description

This commit is contained in:
Féry Mathieu (Mathius)
2022-02-25 02:11:30 +01:00
parent bf599284ed
commit 78c447829a
2 changed files with 14 additions and 3 deletions

View File

@@ -365,3 +365,14 @@ def fetch_random_instance
return filtered_instance_list.sample(1)[0]
end
def reduce_uri(uri : URI | String, max_length : Int32? = 50, suffix : String? = "...") : String
str = uri.to_s.sub(/https?:\/\//, "")
if !max_length.nil? && str.size > max_length
str = str[0, max_length]
if !suffix.nil?
str = "#{str}#{suffix}"
end
end
return str
end