From dfd51cb0379936a5cc90b980ddf46b170f3b365b Mon Sep 17 00:00:00 2001 From: vlakoff Date: Mon, 31 Mar 2014 20:41:07 +0200 Subject: Refactoring in Config->__construct() Put the $_SERVER['HTTP_HOST'] fallback in a more logical place. --- system/core/Config.php | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/system/core/Config.php b/system/core/Config.php index f630d1709..56259bd06 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -76,16 +76,9 @@ class CI_Config { // Set the base_url automatically if none was provided if (empty($this->config['base_url'])) { - if (isset($_SERVER['HTTP_HOST'])) - { - $base_url = is_https() ? 'https' : 'http'; - $base_url .= '://'.$_SERVER['HTTP_HOST'] - .str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']); - } - else - { - $base_url = 'http://localhost/'; - } + $base_url = (is_https() ? 'https' : 'http') . '://' + . (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'localhost') + . str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']); $this->set_item('base_url', $base_url); } -- cgit v1.2.3-24-g4f1b