Skip to content

Commit

Permalink
Using stpos to remove colon character
Browse files Browse the repository at this point in the history
  • Loading branch information
peter279k committed Jun 25, 2018
1 parent 916a8e1 commit fd26bea
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/Purl/Fragment.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ public function __toString() : string
protected function doInitialize() : void
{
if ($this->fragment !== null) {
$pos = strpos($this->fragment, ':', 1);
if ($pos !== false) {
$this->fragment = substr($this->fragment, 0, $pos);
}
$data = parse_url($this->fragment);
if ($data === false) {
$data = ['path' => $this->fragment];
Expand Down
2 changes: 1 addition & 1 deletion tests/Purl/Test/UrlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ public function testRelativeUrl() : void

// test fragment with colon
$url = new Url('http://example.com/#hello:123');
$this->assertEquals('http://example.com/', (string) $url);
$this->assertEquals('http://example.com/#hello', (string) $url);
}
}

Expand Down

0 comments on commit fd26bea

Please sign in to comment.