Skip to content

Commit

Permalink
add extra test
Browse files Browse the repository at this point in the history
  • Loading branch information
freekmurze committed Nov 14, 2016
1 parent fadbced commit a7a6a1b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Url.php
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ public function __toString()
$url .= $this->getAuthority();
}

$url .= $this->getPath();
$url .= rtrim($this->getPath(), '/');

if ($this->getQuery() !== '') {
$url .= '?'.$this->getQuery();
Expand All @@ -316,7 +316,7 @@ public function __toString()
$url .= '#'.$this->getFragment();
}

return rtrim($url, '/');
return $url;
}

public function __clone()
Expand Down
11 changes: 11 additions & 0 deletions tests/UrlBuildTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,15 @@ public function it_can_build_a_url_with_the_full_monty()
$url->__toString()
);
}

/** @test */
public function it_prefixes_the_path_if_the_url_has_an_authority_but_is_rootless()
{
$url = Url::create()
->withUserInfo('sebastian', 'supersecret')
->withPort(9000)
->withPath('opensource');

$this->assertEquals('//sebastian:supersecret@:9000/opensource', $url->__toString());
}
}

0 comments on commit a7a6a1b

Please sign in to comment.