X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FUtil%2FStrings.php;h=bc1a0e4be991e751634c016ae1c5177ea06377bd;hb=e1863951986ba5be173758324a00652bc5af870c;hp=1ce1ac8c7d17a05f6788dcf5b3fd8dc7991b3396;hpb=c4c80ed3cce6d11a4350b62ee055da9160a2fdfd;p=friendica.git diff --git a/src/Util/Strings.php b/src/Util/Strings.php index 1ce1ac8c7d..bc1a0e4be9 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'] . '://www.', $parts['scheme'] . '://']; + $styled_url = str_replace($scheme, '', $url); + + if (strlen($styled_url) > 30) { + $styled_url = substr($styled_url, 0, 30) . "…"; + } + + return $styled_url; + } }