Skip to content

Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥

fix(v1/map): handle invalid URLs gracefully

Gergő Móriczad1a6fbc74ee
diff --git a/apps/api/src/controllers/v1/map.ts b/apps/api/src/controllers/v1/map.ts
index e6abd9ae6..a9c61d04b 100644
--- a/apps/api/src/controllers/v1/map.ts
+++ b/apps/api/src/controllers/v1/map.ts
@@ -88,7 +88,13 @@ export async function mapController(
links = performCosineSimilarity(links, searchQuery);
}
- links = links.map((x) => checkAndUpdateURLForMap(x).url.trim());
+ links = links.map((x) => {
+ try {
+ return checkAndUpdateURLForMap(x).url.trim()
+ } catch (_) {
+ return null;
+ }
+ }).filter(x => x !== null);
// allows for subdomains to be included
links = links.filter((x) => isSameDomain(x, req.body.url));