From 3a02f1d7a4273ac955ee568c881d53ce0a8bbc96 Mon Sep 17 00:00:00 2001 From: Yann Bizeul Date: Wed, 30 Apr 2025 09:49:41 +0200 Subject: [PATCH] new: if description is an url, it is now clickable --- html/src/Components/ShareComponent.tsx | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/html/src/Components/ShareComponent.tsx b/html/src/Components/ShareComponent.tsx index 24fbe93..05f3aab 100644 --- a/html/src/Components/ShareComponent.tsx +++ b/html/src/Components/ShareComponent.tsx @@ -48,6 +48,16 @@ export function ShareComponent(props: {share: Share}) { }) } + const linkify = (text: string) => { + const urlRegex = /[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/ + if (urlRegex.test(text)) { + return {text} + } + else { + return text + } + } + if (deleted) { return } @@ -107,16 +117,16 @@ export function ShareComponent(props: {share: Share}) { } {/* Share informations */} - - - + + + {/* Share name */} - - + + {name} - - {share.options.description?share.options.description + + {share.options.description?linkify(share.options.description) : t("created") + " " + new Date(share.created).toLocaleString(locales,{dateStyle:"long",timeStyle:"short"}) }