Skip to content

Commit 351c4ae

Browse files
committed
Fix VFB ID links to display preferred labels (e.g., ME on JRC2018Unisex) instead of raw IDs
1 parent aec0fc7 commit 351c4ae

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

app/api/chat/route.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,16 @@ function replaceTermsWithLinks(text) {
634634
})
635635
}
636636

637+
// Link raw VFB/FBbt IDs using their preferred short label when available.
638+
// This makes e.g. "VFB_00102107" render as "%label%" but still link to the report.
639+
result = result.replace(/\b(FBbt_\d{8}|VFB_\d{8})\b/g, (match) => {
640+
const label = reverseLookupCache?.[match]
641+
const display = label || match
642+
const link = `[${display}](${REPORT_BASE + encodeURIComponent(match)})`
643+
allLinks.push(link)
644+
return `\x00LINK${allLinks.length - 1}\x00`
645+
})
646+
637647
result = result.replace(/\x00LINK(\d+)\x00/g, (_, idx) => allLinks[parseInt(idx)])
638648

639649
return result

0 commit comments

Comments
 (0)