diff --git a/CHANGELOG.md b/CHANGELOG.md index e19f64f01..24489165c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,19 @@ +# v1.1.0 +## XX/XX/2016 + +1. [](#new) + * +1. [](#improved) + * Now supporting hostnames with localhost environments for better vhost support/development +1. [](#bugfix) + * + # v1.0.10 ## 02/11/2016 1. [](#new) * Added new `Page::contentMeta()` mechanism to store content-level meta data alongside content - * Added Japanese language translation + * Added Japanese language translation 1. [](#improved) * Updated some vendor libraries 1. [](#bugfix) @@ -18,7 +28,7 @@ * New **page-level SSL** functionality when using `absolute_urls` * Added `reverse_proxy` config option for issues with non-standard ports * Added `proxy_url` config option to support GPM behind proxy servers #639 - * New `Pages::parentsRawRoutes()` method + * New `Pages::parentsRawRoutes()` method * Enhanced `bin/gpm info` CLI command with Changelog support #559 * Ability to add empty *Folder* via admin plugin * Added latest `jQuery 2.2.0` library to core diff --git a/system/src/Grav/Common/Uri.php b/system/src/Grav/Common/Uri.php index 8b6a0aaf7..7a9e536e7 100644 --- a/system/src/Grav/Common/Uri.php +++ b/system/src/Grav/Common/Uri.php @@ -159,17 +159,12 @@ class Uri private function buildEnvironment() { - // set hostname - $address = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '::1'; - // check for localhost variations - if ($this->name == 'localhost' || $address == '::1' || $address == '127.0.0.1') { - $env = 'localhost'; + if ($this->name == '127.0.0.1' || $this->name== '::1') { + return 'localhost'; } else { - $env = $this->name; + return $this->name; } - - return $env; } /** @@ -479,7 +474,7 @@ class Uri * Gets the Fragment portion of a URI (eg #target) * * @param null $fragment - * + * * @return null */ public function fragment($fragment = null) diff --git a/tests/unit/Grav/Common/UriTest.php b/tests/unit/Grav/Common/UriTest.php index 70887da46..d2299ac06 100644 --- a/tests/unit/Grav/Common/UriTest.php +++ b/tests/unit/Grav/Common/UriTest.php @@ -273,19 +273,16 @@ class UriTest extends \Codeception\TestCase\Test public function testEnvironment() { - $address = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '::1'; - if ($this->uri->host() == 'localhost' || $address == '::1' || $address == '127.0.0.1') { - $address = 'localhost'; - } - $this->uri->initializeWithURL('http://localhost/a-page')->init(); - $this->assertSame($address, $this->uri->environment()); + $this->assertSame('localhost', $this->uri->environment()); + $this->uri->initializeWithURL('http://127.0.0.1/a-page')->init(); + $this->assertSame('localhost', $this->uri->environment()); $this->uri->initializeWithURL('http://localhost:8080/a-page')->init(); - $this->assertSame($address, $this->uri->environment()); + $this->assertSame('localhost', $this->uri->environment()); $this->uri->initializeWithURL('http://foobar.it:443/a-page')->init(); - $this->assertSame($address, $this->uri->environment()); + $this->assertSame('foobar.it', $this->uri->environment()); $this->uri->initializeWithURL('https://google.com/a-page')->init(); - $this->assertSame($address, $this->uri->environment()); + $this->assertSame('google.com', $this->uri->environment()); } public function testBasename()