From 46e4a41f5c3a71224e00aa55675c48fc2d2cd10d Mon Sep 17 00:00:00 2001 From: zkldi <20380519+zkldi@users.noreply.github.com> Date: Thu, 13 Oct 2022 00:36:56 +0100 Subject: [PATCH] feat: automatically infer links in your aboutMe --- client/src/app/pages/dashboard/users/UserPage.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/client/src/app/pages/dashboard/users/UserPage.tsx b/client/src/app/pages/dashboard/users/UserPage.tsx index 001f6011a..d38834886 100644 --- a/client/src/app/pages/dashboard/users/UserPage.tsx +++ b/client/src/app/pages/dashboard/users/UserPage.tsx @@ -20,6 +20,10 @@ export default function UserPage({ reqUser }: Props) { return ; } +function InferLinks(aboutMe: string) { + return aboutMe.replace(/(https?:\/\/[^\s]+)(\s)/gu, "[$1]($1)$2"); +} + function AboutMeCard({ reqUser }: Props) { const { user } = useContext(UserContext); @@ -110,7 +114,7 @@ function AboutMeCard({ reqUser }: Props) { )} - {content} + {InferLinks(content)} ); }