From 0559ae3a58f73a4190f7d240abb04a6d5e0a6a3c Mon Sep 17 00:00:00 2001 From: yggverse Date: Sat, 6 Apr 2024 02:48:25 +0300 Subject: [PATCH] fix undefined variable, minor optimization --- src/cli/document/crawl.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/cli/document/crawl.php b/src/cli/document/crawl.php index badea88..4085361 100644 --- a/src/cli/document/crawl.php +++ b/src/cli/document/crawl.php @@ -301,6 +301,10 @@ foreach($index->search('') ); // Crawl links + $base = new \Yggverse\Net\Address( + $document->get('url') + ); + $documents = []; foreach ($body->getLinks() as $line) @@ -318,10 +322,6 @@ foreach($index->search('') if ($address->isRelative()) { - $base = new \Yggverse\Net\Address( - $document->get('url') - ); - if ($absolute = $address->getAbsolute($base)) { $url = $absolute; @@ -335,7 +335,7 @@ foreach($index->search('') } // External host rules - if (!$config->cli->document->crawl->url->external && parse_url($url, PHP_URL_HOST) != $host) + if (!$config->cli->document->crawl->url->external && $address->getHost() != $base->getHost()) { continue; }