From aeee83325fc95c0b96a5692ad58a33a211df699b Mon Sep 17 00:00:00 2001 From: Kevin Decherf Date: Fri, 29 Oct 2021 17:20:37 +0200 Subject: [PATCH] makeAbsolute: remove slash trim as it can break some urls Signed-off-by: Kevin Decherf --- src/Graby.php | 2 -- tests/GrabyTest.php | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Graby.php b/src/Graby.php index 101da073..af5053a5 100644 --- a/src/Graby.php +++ b/src/Graby.php @@ -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); diff --git a/tests/GrabyTest.php b/tests/GrabyTest.php index e72ade5a..3c349b5f 100644 --- a/tests/GrabyTest.php +++ b/tests/GrabyTest.php @@ -823,6 +823,7 @@ public function dataForMakeAbsolute(): array ['http://example.org', 'test', 'src', 'http://domain.com/lol.jpg'], ['http://example.org', '', 'src', 'http://example.org/path/to/image.jpg'], ['http://example.org', 'test', 'src', ''], + ['http://example.org/folder/', '', 'src', 'http://example.org/folder/visual.jpg'], ]; }