refactoring.
This commit is contained in:
parent
997a90bcf5
commit
92694da3a3
|
@ -243,10 +243,10 @@ public function send()
|
||||||
/**
|
/**
|
||||||
* 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 @@ public static function to($url = '', $https = false)
|
||||||
{
|
{
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue