mirror of
https://github.com/getgrav/grav.git
synced 2026-07-07 08:42:22 +02:00
Added support for external URL in directs
This commit is contained in:
@@ -255,7 +255,13 @@ class Grav extends Container
|
||||
$this['session']->close();
|
||||
}
|
||||
|
||||
header("Location: " . rtrim($uri->rootUrl(), '/') .'/'. trim($route, '/'), true, $code);
|
||||
if ($this['uri']->isExternal($route)) {
|
||||
$url = $route;
|
||||
} else {
|
||||
$url = rtrim($uri->rootUrl(), '/') .'/'. trim($route, '/');
|
||||
}
|
||||
|
||||
header("Location: {$url}", true, $code);
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
@@ -378,6 +378,20 @@ class Uri
|
||||
return $ipaddress;
|
||||
|
||||
}
|
||||
/**
|
||||
* Is this an external URL? if it starts with `http` then yes, else false
|
||||
*
|
||||
* @param string $url the URL in question
|
||||
* @return boolean is eternal state
|
||||
*/
|
||||
public function isExternal($url)
|
||||
{
|
||||
if (Utils::startsWith($url, 'http')) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The opposite of built-in PHP method parse_url()
|
||||
|
||||
Reference in New Issue
Block a user