Added support for external URL in directs

This commit is contained in:
Andy Miller
2015-03-16 21:10:31 -06:00
parent 504f57930a
commit db5c3ea400
2 changed files with 21 additions and 1 deletions

View File

@@ -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();
}

View File

@@ -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()