mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-31 01:34:09 +02:00
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
This commit is contained in:
parent
1cffbc9034
commit
7caccd7691
@ -127,10 +127,6 @@ class Url
|
|||||||
$baseUrl = $request->getBaseUrl();
|
$baseUrl = $request->getBaseUrl();
|
||||||
$urlObject->setBaseUrl($baseUrl);
|
$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);
|
$urlParts = parse_url($url);
|
||||||
if (isset($urlParts['path'])) {
|
if (isset($urlParts['path'])) {
|
||||||
if ($baseUrl !== '' && strpos($urlParts['path'], $baseUrl) === 0) {
|
if ($baseUrl !== '' && strpos($urlParts['path'], $baseUrl) === 0) {
|
||||||
@ -144,29 +140,14 @@ class Url
|
|||||||
$params = UrlParams::fromQueryString($urlParts['query'])->mergeValues($params);
|
$params = UrlParams::fromQueryString($urlParts['query'])->mergeValues($params);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($fragment) {
|
if (isset($urlParts['fragment'])) {
|
||||||
$urlObject->setAnchor($fragment);
|
$urlObject->setAnchor($urlParts['fragment']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$urlObject->setParams($params);
|
$urlObject->setParams($params);
|
||||||
return $urlObject;
|
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
|
* Overwrite the baseUrl
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user