Skip to content

Commit

Permalink
remove fragments
Browse files Browse the repository at this point in the history
  • Loading branch information
dantleech committed Jan 27, 2019
1 parent 92f8ecb commit eba2544
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## [Unreleased]

- Unconditionally remove URL fragments.

## [0.2.1] - 2019-01-26

- Use correct autoload path when included as a dependency
Expand Down
5 changes: 5 additions & 0 deletions lib/Model/Url.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ public function resolveUrl($link): self
$link = $link->withPort($this->uri->getPort());
}

if ($link->getFragment()) {
// unconditionally remove fragments
$link = $link->withFragment('');
}

return new self($link, $this, $this->distance + 1);
}

Expand Down
6 changes: 6 additions & 0 deletions tests/Unit/Model/UrlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ public function provideResolve()
'templates.html',
'https://example.com:1234/templates.html'
];

yield 'ignores fragments' => [
'https://example.com',
'#foobar',
'https://example.com'
];
}

public function testIsHttp()
Expand Down

0 comments on commit eba2544

Please sign in to comment.