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

Commit 4efe109

Browse files
committed
Fixes #93 : withFragment() deviates from PSR-7
1 parent 5587c48 commit 4efe109

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/Uri.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ private function splitQueryValue($value)
627627
private function filterFragment($fragment)
628628
{
629629
if (! empty($fragment) && strpos($fragment, '#') === 0) {
630-
$fragment = substr($fragment, 1);
630+
$fragment = urlencode('#') . substr($fragment, 1);
631631
}
632632

633633
return $this->filterQueryOrFragment($fragment);

test/UriTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ public function testStripsFragmentPrefixIfPresent()
331331
{
332332
$uri = new Uri('http://example.com');
333333
$new = $uri->withFragment('#/foo/bar');
334-
$this->assertEquals('/foo/bar', $new->getFragment());
334+
$this->assertEquals('%23/foo/bar', $new->getFragment());
335335
}
336336

337337
public function standardSchemePortCombinations()

0 commit comments

Comments
 (0)