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

Commit e022b52

Browse files
committed
Alternate fixes #192
1 parent b4e7758 commit e022b52

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

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: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,4 +568,11 @@ public function testUtf8Uri()
568568

569569
$this->assertEquals('ουτοπία.δπθ.gr', $uri->getHost());
570570
}
571+
572+
public function testUriDoesNotAppendColonToHostIfPortIsEmpty()
573+
{
574+
$uri = (new Uri())->withHost('google.com');
575+
$this->assertEquals('google.com', (string) $uri);
576+
$this->assertNotEquals('google.com:', (string) $uri);
577+
}
571578
}

0 commit comments

Comments
 (0)