From e8aba03f2b3f3be6660910ae30c5f2bd056f7ee0 Mon Sep 17 00:00:00 2001 From: IgorA100 Date: Sat, 14 Oct 2023 23:49:34 +0300 Subject: [PATCH] Fix: Relative URLs in links Feed discovery with relative URLs in links Example: https://k47.cz/ Solution to the problem: #417 --- src/FeedIo/Explorer.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/FeedIo/Explorer.php b/src/FeedIo/Explorer.php index eb0b86d..64637ba 100644 --- a/src/FeedIo/Explorer.php +++ b/src/FeedIo/Explorer.php @@ -29,7 +29,7 @@ public function discover(string $url): array $stream = $this->client->getResponse($url, new DateTime('@0')); $internalErrors = libxml_use_internal_errors(true); - $feeds = $this->extractFeeds($stream->getBody()); + $feeds = $this->extractFeeds($stream->getBody(), $url); libxml_use_internal_errors($internalErrors); @@ -53,6 +53,9 @@ protected function extractFeeds(string $html): array // returning $href = 'https:' . $href; } + if (!parse_url($href, PHP_URL_HOST) && $url){ + $href = parse_url($url, PHP_URL_SCHEME) . '://' . parse_url($url, PHP_URL_HOST) . '/' . ltrim($href,'/'); + } $feeds[] = $href; } }