diff --git a/src/components/Chat/MessageDisplay.tsx b/src/components/Chat/MessageDisplay.tsx index 0800186..822f04b 100644 --- a/src/components/Chat/MessageDisplay.tsx +++ b/src/components/Chat/MessageDisplay.tsx @@ -4,12 +4,11 @@ import './styles.css'; import { executeEvent } from '../../utils/events'; const extractComponents = (url) => { - console.log('url', url); - if (!url.startsWith("qortal://")) { + if (!url || !url.startsWith("qortal://")) { // Check if url exists and starts with "qortal://" return null; } - url = url.replace(/^(qortal\:\/\/)/, ""); + url = url.replace(/^(qortal\:\/\/)/, ""); // Safe to use replace now if (url.includes("/")) { let parts = url.split("/"); const service = parts[0].toUpperCase(); @@ -59,6 +58,8 @@ function processText(input) { export const MessageDisplay = ({ htmlContent, isReply }) => { const linkify = (text) => { + if (!text) return ""; // Return an empty string if text is null or undefined + let textFormatted = text; const urlPattern = /(\bhttps?:\/\/[^\s<]+|\bwww\.[^\s<]+)/g; textFormatted = text.replace(urlPattern, (url) => {