Support localhost environments based on hostname for vhost support - #772

This commit is contained in:
Andy Miller
2016-04-06 12:03:39 -06:00
parent 993c10df10
commit d349e5d67b
3 changed files with 22 additions and 20 deletions

View File

@@ -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

View File

@@ -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)

View File

@@ -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()