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

Commit

Permalink
Merge pull request #235 from ajgarlag/master
Browse files Browse the repository at this point in the history
Prefix authority with double slash if present.
  • Loading branch information
weierophinney committed Apr 6, 2017
2 parents 8a71cfc + 95e0522 commit 1ebb557
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/Uri.php
Original file line number Diff line number Diff line change
Expand Up @@ -470,11 +470,11 @@ private static function createUriString($scheme, $authority, $path, $query, $fra
$uri = '';

if (! empty($scheme)) {
$uri .= sprintf('%s://', $scheme);
$uri .= sprintf('%s:', $scheme);
}

if (! empty($authority)) {
$uri .= $authority;
$uri .= '//' . $authority;
}

if ($path) {
Expand Down
8 changes: 7 additions & 1 deletion test/UriTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,12 @@ public function utf8QueryStringsDataProvider()
public function testUriDoesNotAppendColonToHostIfPortIsEmpty()
{
$uri = (new Uri())->withHost('google.com');
$this->assertEquals('google.com', (string) $uri);
$this->assertEquals('//google.com', (string) $uri);
}

public function testAuthorityIsPrefixedByDoubleSlashIfPresent()
{
$uri = (new Uri())->withHost('example.com');
$this->assertEquals('//example.com', (string) $uri);
}
}

0 comments on commit 1ebb557

Please sign in to comment.