From 3b93a3510811982d31cda8a023a77336bd0fb0a9 Mon Sep 17 00:00:00 2001 From: Maxence Lange Date: Mon, 10 Jul 2023 10:47:37 -0100 Subject: display displayname on federated shares Signed-off-by: Maxence Lange --- lib/private/Federation/CloudIdManager.php | 11 ++++++----- lib/public/Federation/ICloudIdManager.php | 10 ++++++++++ 2 files changed, 16 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/private/Federation/CloudIdManager.php b/lib/private/Federation/CloudIdManager.php index 85aae8e5ec5..82b711bd422 100644 --- a/lib/private/Federation/CloudIdManager.php +++ b/lib/private/Federation/CloudIdManager.php @@ -209,11 +209,12 @@ class CloudIdManager implements ICloudIdManager { * @param string $url * @return string */ - private function removeProtocolFromUrl($url) { - if (strpos($url, 'https://') === 0) { - return substr($url, strlen('https://')); - } elseif (strpos($url, 'http://') === 0) { - return substr($url, strlen('http://')); + public function removeProtocolFromUrl(string $url): string { + if (str_starts_with($url, 'https://')) { + return substr($url, 8); + } + if (str_starts_with($url, 'http://')) { + return substr($url, 7); } return $url; diff --git a/lib/public/Federation/ICloudIdManager.php b/lib/public/Federation/ICloudIdManager.php index 1612c03ba4a..52920751739 100644 --- a/lib/public/Federation/ICloudIdManager.php +++ b/lib/public/Federation/ICloudIdManager.php @@ -62,4 +62,14 @@ interface ICloudIdManager { * @since 12.0.0 */ public function isValidCloudId(string $cloudId): bool; + + /** + * remove scheme/protocol from an url + * + * @param string $url + * + * @return string + * @since 28.0.0 + */ + public function removeProtocolFromUrl(string $url): string; } -- cgit v1.2.3