X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FUtil%2FStrings.php;h=12503528fb480d8279bbe7ae8d448e8868c5e717;hb=d4a5a8051ad34a7be72238967afb3e6b140afdc8;hp=1ce1ac8c7d17a05f6788dcf5b3fd8dc7991b3396;hpb=4eec2804de78a6aeb30f843b3b295a563f78a3fe;p=friendica.git diff --git a/src/Util/Strings.php b/src/Util/Strings.php index 1ce1ac8c7d..12503528fb 100644 --- a/src/Util/Strings.php +++ b/src/Util/Strings.php @@ -23,7 +23,6 @@ namespace Friendica\Util; use Friendica\Content\ContactSelector; use Friendica\Core\Logger; -use Friendica\Core\System; use ParagonIE\ConstantTime\Base64; /** @@ -511,7 +510,7 @@ class Strings ); if (is_null($return)) { - Logger::notice('Received null value from preg_replace_callback', ['text' => $text, 'regex' => $regex, 'blocks' => $blocks, 'executionId' => $executionId, 'callstack' => System::callstack(10)]); + Logger::notice('Received null value from preg_replace_callback', ['text' => $text, 'regex' => $regex, 'blocks' => $blocks, 'executionId' => $executionId]); } $text = $callback($return ?? $text) ?? ''; @@ -561,4 +560,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; + } }