From c2105f93d1edf4f9d1b566cc4f69005ae335de81 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Thu, 21 May 2020 00:23:14 -0400 Subject: [PATCH] Remove duplicate curl call in Network\Probe::getFeedLink - Add page body argument instead - Expand method scope to allow tests --- src/Network/Probe.php | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/Network/Probe.php b/src/Network/Probe.php index edcb9f4c34..65ce67d6bf 100644 --- a/src/Network/Probe.php +++ b/src/Network/Probe.php @@ -1756,25 +1756,20 @@ class Probe } /** - * Check page for feed link + * Checks HTML page for RSS feed link * - * @param string $url Page link - * - * @return string feed link + * @param string $url Page link + * @param string $body Page body string + * @return string|false Feed link or false if body was invalid HTML document */ - private static function getFeedLink($url) + public static function getFeedLink(string $url, string $body) { - $curlResult = Network::curl($url); - if (!$curlResult->isSuccess()) { - return false; - } - $doc = new DOMDocument(); - if (!@$doc->loadHTML($curlResult->getBody())) { + if (!@$doc->loadHTML($body)) { return false; } - $xpath = new DomXPath($doc); + $xpath = new DOMXPath($doc); //$feeds = $xpath->query("/html/head/link[@type='application/rss+xml']"); $feeds = $xpath->query("/html/head/link[@type='application/rss+xml' and @rel='alternate']"); @@ -1826,7 +1821,7 @@ class Probe return false; } - $feed_url = self::getFeedLink($url); + $feed_url = self::getFeedLink($url, $feed); if (!$feed_url) { return false; -- 2.39.5