From 071505f024d18aba07fb2447f76f59fbe7f3ff78 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 22 May 2020 04:52:43 +0000 Subject: [PATCH] Added documentation, simplified code --- src/Model/GServer.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/Model/GServer.php b/src/Model/GServer.php index 08663fa065..560c0831d7 100644 --- a/src/Model/GServer.php +++ b/src/Model/GServer.php @@ -247,6 +247,12 @@ class GServer Logger::info('Set failed status for new server', ['url' => $url]); } + /** + * Remove unwanted content from the given URL + * + * @param string $url + * @return string cleaned URL + */ public static function cleanURL(string $url) { $url = trim($url, '/'); @@ -260,13 +266,15 @@ class GServer return Network::unparseURL($urlparts); } + /** + * Return the base URL + * + * @param string $url + * @return string base URL + */ private static function getBaseURL(string $url) { - $urlparts = parse_url($url); - unset($urlparts['user']); - unset($urlparts['pass']); - unset($urlparts['query']); - unset($urlparts['fragment']); + $urlparts = parse_url(self::cleanURL($url)); unset($urlparts['path']); return Network::unparseURL($urlparts); }