Skip to content

Commit

Permalink
Fix: Relative URLs in links
Browse files Browse the repository at this point in the history
Feed discovery with relative URLs in links
Example: https://k47.cz/
Solution to the problem: alexdebril#417
  • Loading branch information
IgorA100 authored Oct 14, 2023
1 parent ed94a3c commit e8aba03
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/FeedIo/Explorer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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;
}
}
Expand Down

0 comments on commit e8aba03

Please sign in to comment.