From 92694da3a3306c04e6cf2729d7a3417ecb94a269 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Mon, 31 Oct 2011 22:36:30 -0500 Subject: [PATCH] refactoring. --- laravel/response.php | 8 ++++---- laravel/url.php | 17 ++++++++++++++++- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/laravel/response.php b/laravel/response.php index 7c87e4d3..53ef9d09 100644 --- a/laravel/response.php +++ b/laravel/response.php @@ -243,10 +243,10 @@ public function send() /** * 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. diff --git a/laravel/url.php b/laravel/url.php index 60e8d3a9..815cd3ec 100644 --- a/laravel/url.php +++ b/laravel/url.php @@ -20,14 +20,29 @@ public static function to($url = '', $https = false) { 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; } /**