Skip to content

Commit

Permalink
Revert "Url: Add support macros"
Browse files Browse the repository at this point in the history
This reverts commit 33231d2.
There is no need for url macros, since we're handling absolute
urls correctly now.
  • Loading branch information
Johannes Meyer committed Sep 22, 2015
1 parent 33231d2 commit 81e1310
Showing 1 changed file with 1 addition and 28 deletions.
29 changes: 1 addition & 28 deletions library/Icinga/Web/Url.php
Expand Up @@ -142,7 +142,7 @@ public static function fromPath($url, array $params = array(), $request = null)
return $urlObject;
}

$urlParts = parse_url(static::resolveUrlMacros($url));
$urlParts = parse_url($url);
if (isset($urlParts['scheme']) && $urlParts['scheme'] !== $request->getScheme()) {
$baseUrl = $urlParts['scheme'] . '://' . $urlParts['host'] . (isset($urlParts['port'])
? (':' . $urlParts['port'])
Expand Down Expand Up @@ -189,33 +189,6 @@ public static function fromPath($url, array $params = array(), $request = null)
return $urlObject;
}

/**
* Return the given url with all macros being resolved
*
* @param string $url
*
* @return string
*/
public static function resolveUrlMacros($url)
{
$serverName = static::getRequest()->getServer('SERVER_NAME');
$macros = array(
'HTTP_AUTHORITY' => 'http://' . $serverName,
'HTTPS_AUTHORITY' => 'https://' . $serverName
);

if (preg_match_all('@\$([^\$\s]+)\$@', $url, $matches)) {
foreach ($matches[1] as $macroIndex => $macroName) {
if (isset($macros[$macroName])) {
$placeholder = $matches[0][$macroIndex];
$url = str_replace($placeholder, $macros[$macroName], $url);
}
}
}

return $url;
}

/**
* Create a new filter that needs to fullfill the base filter and the optional filter (if it exists)
*
Expand Down

0 comments on commit 81e1310

Please sign in to comment.