fix: url sanitization

This commit is contained in:
Han Xiao 2025-03-17 21:30:07 +08:00
parent 7d88264b43
commit 47b9e436d5

View File

@ -245,7 +245,11 @@ async function updateReferences(thisStep: AnswerAction, allURLs: Record<string,
if (!normalizedUrl) return null; // This causes the type error
return {
exactQuote: ref?.exactQuote || '',
exactQuote: (ref?.exactQuote ||
allURLs[normalizedUrl]?.description ||
allURLs[normalizedUrl]?.title || '')
.replace(/[^\p{L}\p{N}\s]/gu, ' ')
.replace(/\s+/g, ' '),
title: allURLs[normalizedUrl]?.title || '',
url: normalizedUrl,
dateTime: ref?.dateTime || ''