From 54065431e9e5b4282298e7a3bcdfce8d74393d4c Mon Sep 17 00:00:00 2001 From: Simon Willshire Date: Sun, 6 Apr 2025 20:36:18 +0200 Subject: [PATCH] Fix url depth check out of bounds panic --- internal/crawler/crawler.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/crawler/crawler.go b/internal/crawler/crawler.go index 6e3f5f8..8a6b482 100644 --- a/internal/crawler/crawler.go +++ b/internal/crawler/crawler.go @@ -203,8 +203,9 @@ func (wc *WebCrawler) crawlStandard() ([]domain.Document, error) { } // Don't crawl deeper if we've reached the maximum depth - urlDepth := strings.Count(url[len(wc.baseURL.String()):], "/") - if urlDepth >= wc.maxDepth { + urlDepth := strings.Count(url, "/") + baseDepth := strings.Count(wc.baseURL.String(), "/") + if urlDepth-baseDepth >= wc.maxDepth { continue }