diff --git a/src/components/questions/QuestionSplitView.tsx b/src/components/questions/QuestionSplitView.tsx
index 235ee96..0d5cf30 100644
--- a/src/components/questions/QuestionSplitView.tsx
+++ b/src/components/questions/QuestionSplitView.tsx
@@ -1,6 +1,7 @@
"use client";
import { useState, useEffect, useCallback, useRef } from "react";
+import { linkify } from "@/lib/linkify";
interface FileAttachment {
name: string;
@@ -322,7 +323,7 @@ export function QuestionSplitView({ currentUserId }: { currentUserId: string })
{msg.author.name} · {formatDate(msg.createdAt)}
- {msg.text}
+ {linkify(msg.text)}
{msg.files && msg.files.length > 0 && (
{msg.files.map((f) => (
diff --git a/src/components/questions/QuestionThread.tsx b/src/components/questions/QuestionThread.tsx
index e10edc0..d923ea2 100644
--- a/src/components/questions/QuestionThread.tsx
+++ b/src/components/questions/QuestionThread.tsx
@@ -1,6 +1,7 @@
"use client";
import { useState, useRef, useEffect } from "react";
+import { linkify } from "@/lib/linkify";
interface FileAttachment {
name: string;
@@ -140,7 +141,7 @@ export function QuestionThread({
· 🔵 новое
)}
-
{msg.text}
+
{linkify(msg.text)}
{msg.files && msg.files.length > 0 && (
{msg.files.map((f, i) => (
diff --git a/src/lib/linkify.tsx b/src/lib/linkify.tsx
new file mode 100644
index 0000000..1a56668
--- /dev/null
+++ b/src/lib/linkify.tsx
@@ -0,0 +1,26 @@
+import { Fragment, type ReactNode } from "react";
+
+const URL_RE = /(https?:\/\/[^\s<>()]+[^\s<>().,;:!?])/g;
+
+export function linkify(text: string): ReactNode[] {
+ if (!text) return [];
+ const parts = text.split(URL_RE);
+ return parts.map((part, i) => {
+ if (URL_RE.test(part)) {
+ URL_RE.lastIndex = 0;
+ return (
+
+ {part}
+
+ );
+ }
+ return
{part};
+ });
+}