From d05b9964677b7b2384453329d2ac99d841467053 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Thu, 15 May 2025 22:42:48 +0000 Subject: [PATCH] Fix LLMs.txt cache implementation to use normalizeUrl and exact matching Co-Authored-By: hello@sideguide.dev --- .../src/lib/generate-llmstxt/generate-llmstxt-supabase.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/api/src/lib/generate-llmstxt/generate-llmstxt-supabase.ts b/apps/api/src/lib/generate-llmstxt/generate-llmstxt-supabase.ts index 894307caf..04ca4ff95 100644 --- a/apps/api/src/lib/generate-llmstxt/generate-llmstxt-supabase.ts +++ b/apps/api/src/lib/generate-llmstxt/generate-llmstxt-supabase.ts @@ -17,14 +17,14 @@ export async function getLlmsTextFromCache( return null; } - const originUrl = normalizeUrlOnlyHostname(url); + const originUrl = normalizeUrl(url); try { const { data, error } = await supabase_service .from("llm_texts") .select("*") .eq("origin_url", originUrl) - .gte("max_urls", maxUrls) // Changed to gte since we want cached results with more URLs than requested + .eq("max_urls", maxUrls) // Use exact match instead of gte to ensure cache hits only for exact URL count .order("updated_at", { ascending: false }) .limit(1) .single(); @@ -41,7 +41,7 @@ export async function getLlmsTextFromCache( return null; } - return data.slice(0, maxUrls); + return data; } catch (error) { logger.error("Failed to fetch LLMs text from cache", { error, originUrl }); return null; @@ -58,7 +58,7 @@ export async function saveLlmsTextToCache( return; } - const originUrl = normalizeUrlOnlyHostname(url); + const originUrl = normalizeUrl(url); try { // First check if there's an existing entry