Skip to content

Commit 73e2be4

Browse files
committed
chore: release v3.0.3 (fix thumbnail handling)
1 parent 45e61e1 commit 73e2be4

4 files changed

Lines changed: 31 additions & 2 deletions

File tree

RELEASE_NOTES.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ This file summarizes the release notes inferred from git tags (tag message/annot
44

55
---
66

7+
## v3.0.3
8+
- Release v3.0.3: Fix thumbnail handling by avoiding ID linkification inside existing URLs
9+
710
## v3.0.2
811
- Release v3.0.2: Improve linked ID display by using preferred labels (e.g., “ME on JRC2018Unisex” instead of raw ID)
912

app/api/chat/route.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,15 @@ function replaceTermsWithLinks(text) {
615615
let result = text
616616
const allLinks = []
617617

618+
// Protect existing URLs (including those embedded in markdown/HTML) so we don't
619+
// accidentally rewrite IDs that are already part of a URL.
620+
const urlPlaceholders = []
621+
const URL_PLACEHOLDER = '\x00URL'
622+
result = result.replace(/https?:\/\/[^\s)]+/g, (url) => {
623+
urlPlaceholders.push(url)
624+
return `${URL_PLACEHOLDER}${urlPlaceholders.length - 1}\x00`
625+
})
626+
618627
// Protect existing markdown links and images
619628
result = result.replace(/!?\[([^\]]*)\]\(([^)]+)\)/g, (match) => {
620629
allLinks.push(match)
@@ -645,6 +654,7 @@ function replaceTermsWithLinks(text) {
645654
})
646655

647656
result = result.replace(/\x00LINK(\d+)\x00/g, (_, idx) => allLinks[parseInt(idx)])
657+
result = result.replace(new RegExp(`${URL_PLACEHOLDER}(\\d+)\\x00`, 'g'), (_, idx) => urlPlaceholders[parseInt(idx)])
648658

649659
return result
650660
}

app/page.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,26 @@ export default function Home() {
8989

9090
// Helper: inject VFB term links into responses, so IDs like FBbt_00003748 or VFB_00102107
9191
// become clickable links to the corresponding Virtual Fly Brain report page.
92+
//
93+
// Avoid modifying IDs that are already part of a URL (e.g. https://virtualflybrain.org/reports/VFB_...) as this can break
94+
// thumbnail URLs and other VFB links.
9295
const linkifyVfbTerms = (text) => {
9396
if (!text) return text
97+
98+
const urlPlaceholders = []
99+
const URL_PLACEHOLDER = '\x00URL'
100+
let result = text.replace(/https?:\/\/[^\s)]+/g, (url) => {
101+
urlPlaceholders.push(url)
102+
return `${URL_PLACEHOLDER}${urlPlaceholders.length - 1}\x00`
103+
})
104+
94105
// Avoid double-linking IDs that are already inside markdown links.
95-
return text.replace(/(?<!\[)(?<!\]\()(\b(FBbt_\d{8}|VFB_\d{8})\b)/g, '[$1](https://virtualflybrain.org/reports/$1)')
106+
result = result.replace(/(?<!\[)(?<!\]\()(\b(FBbt_\d{8}|VFB_\d{8})\b)/g, '[$1](https://virtualflybrain.org/reports/$1)')
107+
108+
// Restore protected URLs
109+
result = result.replace(new RegExp(`${URL_PLACEHOLDER}(\\d+)\\x00`, 'g'), (_, idx) => urlPlaceholders[Number(idx)])
110+
111+
return result
96112
}
97113

98114
// Helper: create a message object with a stable unique id

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vfb-chat-client",
3-
"version": "3.0.2",
3+
"version": "3.0.3",
44
"private": true,
55
"scripts": {
66
"dev": "next dev",

0 commit comments

Comments
 (0)