Skip to content

Commit

Permalink
Fix issue jwage#66
Browse files Browse the repository at this point in the history
  • Loading branch information
peter279k committed Jun 24, 2018
1 parent 993f946 commit 916a8e1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Purl/Fragment.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,12 @@ public function __toString() : string
protected function doInitialize() : void
{
if ($this->fragment !== null) {
$this->data = array_merge($this->data, parse_url($this->fragment));
$data = parse_url($this->fragment);
if ($data === false) {
$data = ['path' => $this->fragment];
}

$this->data = array_merge($this->data, $data);
}

foreach ($this->data as $key => $value) {
Expand Down
4 changes: 4 additions & 0 deletions tests/Purl/Test/UrlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,10 @@ public function testRelativeUrl() : void
$url = new Url('/events');
$url->query->set('param1', 'value1');
$this->assertEquals('/events?param1=value1', (string) $url);

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

Expand Down

0 comments on commit 916a8e1

Please sign in to comment.