From 0f1bb3fb3be085b3234d4baa3e512ef927aff4d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9ry=20Mathieu=20=28Mathius=29?= Date: Fri, 25 Feb 2022 11:47:07 +0100 Subject: [PATCH] Update reduce_uri signature Following request_change at : - https://github.com/iv-org/invidious/pull/2936#discussion_r814436660 --- src/invidious/helpers/utils.cr | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/invidious/helpers/utils.cr b/src/invidious/helpers/utils.cr index f8a7873d..8180ab6f 100644 --- a/src/invidious/helpers/utils.cr +++ b/src/invidious/helpers/utils.cr @@ -366,13 +366,10 @@ 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 +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 + if str.size > max_length + str = "#{str[0, max_length]}#{suffix}" end return str end