Commit 92694da3 authored by Taylor Otwell's avatar Taylor Otwell

refactoring.

parent 997a90bc
......@@ -243,10 +243,10 @@ class Response {
/**
* Send all of the response headers to the browser.
*
* The develop may set any response headers they wish using the "header" method.
* All of the headers set by the developer will be automatically sent to the
* browser when the response is sent via the "send" method. There is no need
* to call this method before calling the "send" method.
* The developer may set response headers using the "header" method. All of
* the headers set by the developer will be automatically sent to the browser
* when the response is sent via the "send" method. There is no need to call
* this method before calling the "send" method.
*
* The protocol and status header will be set automatically, as well as the
* content-type and charset, unless those headers have been set explicitly.
......
......@@ -20,14 +20,29 @@ class URL {
{
if (filter_var($url, FILTER_VALIDATE_URL) !== false) return $url;
return rtrim(static::root($https), '/').'/'.ltrim($url, '/');
}
/**
* Get the URL to the root of the application.
*
* @param bool $https
* @return string
*/
protected static function root($https = false)
{
$base = Config::$items['application']['url'].'/'.Config::$items['application']['index'];
// It is possible for the developer to totally disable the generation of links
// that use HTTPS. This is primarily to create a convenient test environment
// when using SSL is not an option. We will only replace the first occurence
// of "http" with "https" since URLs are sometimes passed in query strings.
if ($https and Config::$items['application']['ssl'])
{
$base = preg_replace('~http://~', 'https://', $base, 1);
}
return rtrim($base, '/').'/'.ltrim($url, '/');
return $base;
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment