From 60b664324ab5ebd986a2bcf59744cb8f289edde9 Mon Sep 17 00:00:00 2001 From: Charles T Date: Wed, 29 Nov 2023 22:51:58 +0800 Subject: [PATCH] Update (sitemap) --- .../SitemapCrawler/CustomCrawlProfile.php | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/app/Helpers/FirstParty/SitemapCrawler/CustomCrawlProfile.php b/app/Helpers/FirstParty/SitemapCrawler/CustomCrawlProfile.php index f87839c..5b231f5 100644 --- a/app/Helpers/FirstParty/SitemapCrawler/CustomCrawlProfile.php +++ b/app/Helpers/FirstParty/SitemapCrawler/CustomCrawlProfile.php @@ -7,19 +7,22 @@ class CustomCrawlProfile extends CrawlProfile { + /** @var callable */ + protected $callback; + + public function shouldCrawlCallback(callable $callback): void + { + $this->callback = $callback; + } + public function shouldCrawl(UriInterface $url): bool { - // Check if the host is not 'localhost' - if ($url->getHost() !== 'localhost') { - return false; - } - - // Check if there are query parameters in the URL if ($url->getQuery() !== '') { return false; } - // Check if the path is exactly '/' - return $url->getPath() === '/'; + + return ($this->callback)($url); } + }