From 5966f0cc6295dca97e40d5539238f34258c1cb55 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 26 May 2023 14:26:55 +0000 Subject: [PATCH] Function moved to the "Strings" class --- src/Content/Text/BBCode.php | 21 +-------------------- src/Util/Strings.php | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/src/Content/Text/BBCode.php b/src/Content/Text/BBCode.php index eae0bc4326..0e5ee9d4e2 100644 --- a/src/Content/Text/BBCode.php +++ b/src/Content/Text/BBCode.php @@ -508,26 +508,7 @@ class BBCode */ private static function convertUrlForActivityPub(string $url): string { - return sprintf('%s', $url, self::getStyledURL($url)); - } - - /** - * Converts an URL in a nicer format (without the scheme and possibly shortened) - * - * @param string $url URL that is about to be reformatted - * @return string reformatted link - */ - public static function getStyledURL(string $url): string - { - $parts = parse_url($url); - $scheme = $parts['scheme'] . '://'; - $styled_url = str_replace($scheme, '', $url); - - if (strlen($styled_url) > 30) { - $styled_url = substr($styled_url, 0, 30) . "…"; - } - - return $styled_url; + return sprintf('%s', $url, Strings::getStyledURL($url)); } /* diff --git a/src/Util/Strings.php b/src/Util/Strings.php index 1ce1ac8c7d..c3b77ab48c 100644 --- a/src/Util/Strings.php +++ b/src/Util/Strings.php @@ -561,4 +561,22 @@ class Strings return $shorthand; } + /** + * Converts an URL in a nicer format (without the scheme and possibly shortened) + * + * @param string $url URL that is about to be reformatted + * @return string reformatted link + */ + public static function getStyledURL(string $url): string + { + $parts = parse_url($url); + $scheme = $parts['scheme'] . '://'; + $styled_url = str_replace($scheme, '', $url); + + if (strlen($styled_url) > 30) { + $styled_url = substr($styled_url, 0, 30) . "…"; + } + + return $styled_url; + } } -- 2.39.5