From 09df0ab9d3e7127b0e414624288d097aa630fd34 Mon Sep 17 00:00:00 2001 From: Christopher Date: Thu, 22 Jan 2026 16:50:09 -0800 Subject: [PATCH] More fixes --- src/app/api/posts/route.ts | 5 +++-- src/app/api/users/[handle]/posts/route.ts | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/app/api/posts/route.ts b/src/app/api/posts/route.ts index 1c25c0b..bac0560 100644 --- a/src/app/api/posts/route.ts +++ b/src/app/api/posts/route.ts @@ -113,9 +113,10 @@ export async function POST(request: Request) { } } -// Normalize content for deduplication (strip HTML entities, URLs, whitespace) +// Normalize content for deduplication (strip HTML entities, URLs, whitespace, category suffixes) const normalizeForDedup = (content: string): string => { return content + .replace(/Posted into [\w\s-]+/gi, '') // Remove "Posted into [Category]" patterns .replace(/&[a-z]+;/gi, '') // Remove HTML entities like ‘ .replace(/&#\d+;/g, '') // Remove numeric entities .replace(/https?:\/\/[^\s]+/gi, '') // Remove URLs @@ -123,7 +124,7 @@ const normalizeForDedup = (content: string): string => { .replace(/\s+/g, ' ') // Normalize whitespace .toLowerCase() .trim() - .slice(0, 100); // Compare first 100 chars + .slice(0, 50); // Compare first 50 chars (article title) }; // Helper to transform cached remote posts to match local post format diff --git a/src/app/api/users/[handle]/posts/route.ts b/src/app/api/users/[handle]/posts/route.ts index b61941f..623e166 100644 --- a/src/app/api/users/[handle]/posts/route.ts +++ b/src/app/api/users/[handle]/posts/route.ts @@ -71,9 +71,10 @@ const stripFirstUrl = (text: string, url: string) => { return `${before} ${after}`.trim(); }; -// Normalize content for deduplication (strip HTML entities, URLs, whitespace) +// Normalize content for deduplication (strip HTML entities, URLs, whitespace, category suffixes) const normalizeForDedup = (content: string): string => { return content + .replace(/Posted into [\w\s-]+/gi, '') // Remove "Posted into [Category]" patterns .replace(/&[a-z]+;/gi, '') // Remove HTML entities like ‘ .replace(/&#\d+;/g, '') // Remove numeric entities .replace(/https?:\/\/[^\s]+/gi, '') // Remove URLs @@ -81,7 +82,7 @@ const normalizeForDedup = (content: string): string => { .replace(/\s+/g, ' ') // Normalize whitespace .toLowerCase() .trim() - .slice(0, 100); // Compare first 100 chars + .slice(0, 50); // Compare first 50 chars (article title) }; const parseRemoteHandle = (handle: string) => {