Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥
TypeScript aiai-agentsai-crawlerai-scrapingai-searchcrawlerdata-extractionhtml-to-markdownllmmarkdownscraperscrapingweb-crawlerweb-dataweb-data-extractionweb-scraperweb-scrapingweb-searchwebscraping
fix: filter out invalid URLs from crawl links
Gergő Móricz55009e51f533
diff --git a/apps/api/src/scraper/WebScraper/crawler.ts b/apps/api/src/scraper/WebScraper/crawler.tsindex af3a9d696..02894cfc8 100644--- a/apps/api/src/scraper/WebScraper/crawler.ts+++ b/apps/api/src/scraper/WebScraper/crawler.ts@@ -267,9 +267,18 @@ export class WebCrawler {public filterURL(href: string, url: string): string | null {let fullUrl = href;if (!href.startsWith("http")) {- fullUrl = new URL(href, this.baseUrl).toString();+ try {+ fullUrl = new URL(href, this.baseUrl).toString();+ } catch (_) {+ return null;+ }+ }+ let urlObj;+ try {+ urlObj = new URL(fullUrl);+ } catch (_) {+ return null;}- const urlObj = new URL(fullUrl);const path = urlObj.pathname;if (this.isInternalLink(fullUrl)) { // INTERNAL LINKS