 
 /// Receiver of crawler-related events.
 public protocol CrawlerDelegate: AnyObject {
+
+  /// Called before the crawler visits a webpage.
+  ///
+  /// A skipped webpage is not considered among the visited pages.
+  func crawler(_ crawler: Crawler, shouldVisitUrl url: URL) -> Bool
 
   /// Called whenever the crawler is about to visit a new webpage.
   func crawler(_ crawler: Crawler, willVisitUrl url: URL)

  func crawlerDidFinish(_ crawler: Crawler)
}

extension CrawlerDelegate {
  // Make crawler(crawler:url:) optional.
  func crawler(_ crawler: Crawler, willVisitUrl url: URL) {}
}


      return
    }

    if
      visitedPages.contains(pageToVisit) {
      crawl()
    } else {
      if delegate?.crawler(self, shouldVisitUrl: pageToVisit) == true {
        visit(page: pageToVisit)
      } else {
        crawl()
      }
    }
  }

