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

refactoring.

parent 997a90bc
...@@ -243,10 +243,10 @@ class Response { ...@@ -243,10 +243,10 @@ class Response {
/** /**
* Send all of the response headers to the browser. * Send all of the response headers to the browser.
* *
* The develop may set any response headers they wish using the "header" method. * The developer may set response headers using the "header" method. All of
* All of the headers set by the developer will be automatically sent to the * the headers set by the developer will be automatically sent to the browser
* browser when the response is sent via the "send" method. There is no need * when the response is sent via the "send" method. There is no need to call
* to call this method before calling the "send" method. * this method before calling the "send" method.
* *
* The protocol and status header will be set automatically, as well as the * The protocol and status header will be set automatically, as well as the
* content-type and charset, unless those headers have been set explicitly. * content-type and charset, unless those headers have been set explicitly.
......
...@@ -20,14 +20,29 @@ class URL { ...@@ -20,14 +20,29 @@ class URL {
{ {
if (filter_var($url, FILTER_VALIDATE_URL) !== false) return $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']; $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']) if ($https and Config::$items['application']['ssl'])
{ {
$base = preg_replace('~http://~', 'https://', $base, 1); $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