mirror of
https://github.com/getgrav/grav.git
synced 2026-05-07 15:27:16 +02:00
Support localhost environments based on hostname for vhost support - #772
This commit is contained in:
14
CHANGELOG.md
14
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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user