mirror of
https://github.com/khoj-ai/khoj.git
synced 2025-02-17 08:04:21 +00:00
Do not render references with broken links in chat view
This commit is contained in:
parent
b98a0cfe1b
commit
5fccccfdff
1 changed files with 10 additions and 3 deletions
|
@ -92,12 +92,19 @@ interface OnlineReferenceCardProps extends OnlineReferenceData {
|
||||||
function GenericOnlineReferenceCard(props: OnlineReferenceCardProps) {
|
function GenericOnlineReferenceCard(props: OnlineReferenceCardProps) {
|
||||||
const [isHovering, setIsHovering] = useState(false);
|
const [isHovering, setIsHovering] = useState(false);
|
||||||
|
|
||||||
if (!props.link) {
|
if (!props.link || props.link.split(' ').length > 1) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const domain = new URL(props.link).hostname;
|
let favicon = `https://www.google.com/s2/favicons?domain=globe`;
|
||||||
const favicon = `https://www.google.com/s2/favicons?domain=${domain}`;
|
let domain = "unknown";
|
||||||
|
try {
|
||||||
|
domain = new URL(props.link).hostname;
|
||||||
|
favicon = `https://www.google.com/s2/favicons?domain=${domain}`;
|
||||||
|
} catch (error) {
|
||||||
|
console.warn(`Error parsing domain from link: ${props.link}`);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
const handleMouseEnter = () => {
|
const handleMouseEnter = () => {
|
||||||
setIsHovering(true);
|
setIsHovering(true);
|
||||||
|
|
Loading…
Add table
Reference in a new issue