Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Commit

Permalink
Merge a8b8cff into 87928a5
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik authored Jul 7, 2018
2 parents 87928a5 + a8b8cff commit 1c8490f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Uri.php
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,9 @@ private function parseUri($uri)

$this->scheme = isset($parts['scheme']) ? $this->filterScheme($parts['scheme']) : '';
$this->userInfo = isset($parts['user']) ? $this->filterUserInfoPart($parts['user']) : '';
$this->host = isset($parts['host']) ? strtolower($parts['host']) : '';
$this->host = isset($parts['host'])
? strtolower($parts['host']) . ($this->scheme === 'https' && (isset($parts['port']) && $parts['port'] != 80) ? ':' . $parts['port'] : null)
: '';
$this->port = isset($parts['port']) ? $parts['port'] : null;
$this->path = isset($parts['path']) ? $this->filterPath($parts['path']) : '';
$this->query = isset($parts['query']) ? $this->filterQuery($parts['query']) : '';
Expand Down
17 changes: 17 additions & 0 deletions test/UriTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,23 @@ public function testHostIsLowercaseWhenIsSetViwWithHost()
$this->assertSame('new-host.com', $uri->getHost());
}

public function testGetHttpsHostWithSpecifiedPort()
{
$uri = new Uri('https://example.com:443');
$this->assertSame('example.com:443', $uri->getHost());
}

public function testGetHttpsHostWithoutSpecifiedPort()
{
$uri = new Uri('https://example.com');
$this->assertSame('example.com', $uri->getHost());
}

public function testGetHttpHostWithSpecifiedPort()
{
$uri = new Uri('http://example.com:80');
$this->assertSame('example.com', $uri->getHost());
}

public function testUriDistinguishZeroFromEmptyString()
{
Expand Down

0 comments on commit 1c8490f

Please sign in to comment.