Skip to content

Commit 33a7bbf

Browse files
committed
fix: Avoid crashing on non-string element
Apparently, the `ChatItemLabel` can receive label that is not string. That was causing crash on assistant.
1 parent d92e0d1 commit 33a7bbf

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

packages/cozy-search/src/components/Conversations/ChatItemLabel.jsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,17 @@ import Markdown from 'cozy-ui/transpiled/react/Markdown'
1010
* @returns {string} sanitized content
1111
*/
1212
const sanitizeContent = content => {
13+
if (!content) {
14+
return ''
15+
}
1316
return content
1417
.replace(/\s?\[REF\][\s\S]*?\[\/REF\]/g, '')
1518
.replace(/\s?\[doc_\d+\]/g, '')
1619
}
1720

1821
const ChatItemLabel = ({ label }) => {
19-
const content = sanitizeContent(label)
2022
if (typeof label === 'string') {
23+
const content = sanitizeContent(label)
2124
return <Markdown content={content} />
2225
}
2326

0 commit comments

Comments
 (0)