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

Commit 1eda638

Browse files
committed
Merge pull request #151 from samsonasik/hotfix/withfragment
Fixes #93 : withFragment() deviates from PSR-7
2 parents d8d8ad2 + 63dad4d commit 1eda638

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
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 = '%23' . substr($fragment, 1);
631631
}
632632

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

test/UriTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,11 +388,11 @@ public function testStripsQueryPrefixIfPresent()
388388
$this->assertEquals('foo=bar', $new->getQuery());
389389
}
390390

391-
public function testStripsFragmentPrefixIfPresent()
391+
public function testEncodeFragmentPrefixIfPresent()
392392
{
393393
$uri = new Uri('http://example.com');
394394
$new = $uri->withFragment('#/foo/bar');
395-
$this->assertEquals('/foo/bar', $new->getFragment());
395+
$this->assertEquals('%23/foo/bar', $new->getFragment());
396396
}
397397

398398
public function standardSchemePortCombinations()

0 commit comments

Comments
 (0)