Skip to content

Commit

Permalink
makeAbsolute: remove slash trim as it can break some urls
Browse files Browse the repository at this point in the history
Signed-off-by: Kevin Decherf <kevin@kdecherf.com>
  • Loading branch information
Kdecherf committed Oct 29, 2021
1 parent 75c8251 commit aeee833
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 2 deletions.
2 changes: 0 additions & 2 deletions src/Graby.php
Original file line number Diff line number Diff line change
Expand Up @@ -779,8 +779,6 @@ private function getSinglePage($html, $url)
*/
private function makeAbsolute($base, \DOMElement $elem)
{
$base = trim($base, '/');

foreach (['a' => 'href', 'img' => 'src', 'iframe' => 'src'] as $tag => $attr) {
$elems = $elem->getElementsByTagName($tag);

Expand Down
1 change: 1 addition & 0 deletions tests/GrabyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -823,6 +823,7 @@ public function dataForMakeAbsolute(): array
['http://example.org', '<img src="//domain.com/lol.jpg">test</img>', 'src', 'http://domain.com/lol.jpg'],
['http://example.org', '<img src=" /path/to/image.jpg" />', 'src', 'http://example.org/path/to/image.jpg'],
['http://example.org', '<a href="/lol">test</a>', 'src', ''],
['http://example.org/folder/', '<img src="visual.jpg" />', 'src', 'http://example.org/folder/visual.jpg'],
];
}

Expand Down

0 comments on commit aeee833

Please sign in to comment.