diff --git a/nginx/vue/src/components/util/Chat.vue b/nginx/vue/src/components/util/Chat.vue index 346a27d..c1610db 100644 --- a/nginx/vue/src/components/util/Chat.vue +++ b/nginx/vue/src/components/util/Chat.vue @@ -49,6 +49,25 @@ function isSafeFileUrl(url) { return typeof url === "string" && url.startsWith("/uploads/"); } +const urlRegex = /(https?:\/\/[^\s<]+)/g; + +function parseMessageParts(text) { + const parts = []; + let lastIndex = 0; + let match; + while ((match = urlRegex.exec(text)) !== null) { + if (match.index > lastIndex) { + parts.push({ type: "text", value: text.slice(lastIndex, match.index) }); + } + parts.push({ type: "link", value: match[1] }); + lastIndex = urlRegex.lastIndex; + } + if (lastIndex < text.length) { + parts.push({ type: "text", value: text.slice(lastIndex) }); + } + return parts; +} + onMounted(() => { messagesStore.connect(); }); @@ -66,7 +85,10 @@ onUnmounted(() => { >

{{ message.authorId }}: - {{ message.text }} +