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

Commit 2774665

Browse files
committed
Merge branch 'hotfix/197'
Close #197 Close #194 Fixes #192
2 parents f3eb90b + c1a979e commit 2774665

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ All notable changes to this project will be documented in this file, in reverse
3636
- [#175](https://github.com/zendframework/zend-diactoros/pull/175) updates the
3737
`Request` class to set the `Host` header from the URI host if no header is
3838
already present. (Ensures conformity with PSR-7 specification.)
39+
- [#197](https://github.com/zendframework/zend-diactoros/pull/197) updates the
40+
`Uri` class to ensure that string serialization does not include a colon after
41+
the host name if no port is present in the instance.
3942

4043
## 1.3.5 - 2016-03-17
4144

src/Uri.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,9 @@ private static function createUriString($scheme, $authority, $path, $query, $fra
507507
private function isNonStandardPort($scheme, $host, $port)
508508
{
509509
if (! $scheme) {
510+
if ($host && ! $port) {
511+
return false;
512+
}
510513
return true;
511514
}
512515

test/UriTest.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,6 @@ public function testUtf8Uri()
569569
$this->assertEquals('ουτοπία.δπθ.gr', $uri->getHost());
570570
}
571571

572-
573572
/**
574573
* @dataProvider utf8PathsDataProvider
575574
*/
@@ -588,4 +587,10 @@ public function utf8PathsDataProvider()
588587
['http://example.com/ουτοπία/', '/ουτοπία/']
589588
];
590589
}
590+
591+
public function testUriDoesNotAppendColonToHostIfPortIsEmpty()
592+
{
593+
$uri = (new Uri())->withHost('google.com');
594+
$this->assertEquals('google.com', (string) $uri);
595+
}
591596
}

0 commit comments

Comments
 (0)