From 7caccd76915fe67579afced7d4cc8e8eb7bd823d Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Tue, 19 Aug 2014 09:36:15 +0200 Subject: [PATCH] Web\Url: remove stripUrlFragment() This function had an interesting history and seems to be a result of missunderstanding of each others commits. Removed, as the fragment is already there. refs #6699 --- library/Icinga/Web/Url.php | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/library/Icinga/Web/Url.php b/library/Icinga/Web/Url.php index ef5a15aa9..84c1a9e49 100644 --- a/library/Icinga/Web/Url.php +++ b/library/Icinga/Web/Url.php @@ -127,10 +127,6 @@ class Url $baseUrl = $request->getBaseUrl(); $urlObject->setBaseUrl($baseUrl); - // Fetch fragment manually and remove it from the url, to 'help' the parse_url() function - // parsing the url properly. Otherwise calling the function with a fragment, but without a - // query will cause unpredictable behaviour. - $fragment = self::stripUrlFragment($url); $urlParts = parse_url($url); if (isset($urlParts['path'])) { if ($baseUrl !== '' && strpos($urlParts['path'], $baseUrl) === 0) { @@ -144,29 +140,14 @@ class Url $params = UrlParams::fromQueryString($urlParts['query'])->mergeValues($params); } - if ($fragment) { - $urlObject->setAnchor($fragment); + if (isset($urlParts['fragment'])) { + $urlObject->setAnchor($urlParts['fragment']); } $urlObject->setParams($params); return $urlObject; } - /** - * Remove the fragment-part of a given url and return it - * - * @param string $url The url to strip its fragment from - * - * @return null|string The stripped fragment, without the '#' - */ - protected static function stripUrlFragment(&$url) - { - if (preg_match('@#(.*)$@', $url, $matches)) { - $url = str_replace('#' . $matches[1], '', $url); - return $matches[1]; - } - } - /** * Overwrite the baseUrl *