From 392f8da2ebc22efeb1b688a75c49c1a52e12f0f2 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 14 Sep 2015 14:52:48 +0300 Subject: Close #4098 --- system/core/Config.php | 20 ++++++++++++++++++-- user_guide_src/source/changelog.rst | 1 + 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/system/core/Config.php b/system/core/Config.php index d07000ac9..feea7c85a 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -238,7 +238,15 @@ class CI_Config { if (isset($protocol)) { - $base_url = $protocol.substr($base_url, strpos($base_url, '://')); + // For protocol-relative links + if ($protocol === '') + { + $base_url = substr($base_url, strpos($base_url, '//')); + } + else + { + $base_url = $protocol.substr($base_url, strpos($base_url, '://')); + } } if (empty($uri)) @@ -293,7 +301,15 @@ class CI_Config { if (isset($protocol)) { - $base_url = $protocol.substr($base_url, strpos($base_url, '://')); + // For protocol-relative links + if ($protocol === '') + { + $base_url = substr($base_url, strpos($base_url, '//')); + } + else + { + $base_url = $protocol.substr($base_url, strpos($base_url, '://')); + } } return $base_url.ltrim($this->_uri_string($uri), '/'); diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index a13f2d2ac..e4250a4e6 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -11,6 +11,7 @@ Release Date: Not Released - Updated the *application/config/constants.php* file to check if constants aren't already defined before doing that. - Changed :doc:`Loader Library ` method ``model()`` to only apply ``ucfirst()`` and not ``strtolower()`` to the requested class name. + - Changed :doc:`Config Library ` methods ``base_url()``, ``site_url()`` to allow protocol-relative URLs by passing an empty string as the protocol. Bug fixes for 3.0.2 ------------------- -- cgit v1.2.3-24-g4f1b