Browse Source

fix undefined variable, minor optimization

gemini
yggverse 9 months ago
parent
commit
0559ae3a58
  1. 10
      src/cli/document/crawl.php

10
src/cli/document/crawl.php

@ -301,6 +301,10 @@ foreach($index->search('')
); );
// Crawl links // Crawl links
$base = new \Yggverse\Net\Address(
$document->get('url')
);
$documents = []; $documents = [];
foreach ($body->getLinks() as $line) foreach ($body->getLinks() as $line)
@ -318,10 +322,6 @@ foreach($index->search('')
if ($address->isRelative()) if ($address->isRelative())
{ {
$base = new \Yggverse\Net\Address(
$document->get('url')
);
if ($absolute = $address->getAbsolute($base)) if ($absolute = $address->getAbsolute($base))
{ {
$url = $absolute; $url = $absolute;
@ -335,7 +335,7 @@ foreach($index->search('')
} }
// External host rules // 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; continue;
} }

Loading…
Cancel
Save