Function moved to the "Strings" class
This commit is contained in:
parent
332b6f21ca
commit
5966f0cc62
2 changed files with 19 additions and 20 deletions
|
@ -508,26 +508,7 @@ class BBCode
|
|||
*/
|
||||
private static function convertUrlForActivityPub(string $url): string
|
||||
{
|
||||
return sprintf('<a href="%s" target="_blank" rel="noopener noreferrer">%s</a>', $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('<a href="%s" target="_blank" rel="noopener noreferrer">%s</a>', $url, Strings::getStyledURL($url));
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue