From 539251c7adff5c52e53af0931b54bb8bbb8858a5 Mon Sep 17 00:00:00 2001 From: Prince Yadav Date: Wed, 17 Jul 2024 02:13:44 +0530 Subject: [PATCH] fix: adding https in checkurltype (#6295) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # Fix URL handling for LinkedIn and Twitter links Fixes #6287 ## Solution Updated `checkUrlType` function to prepend "https://" to URLs if missing, ensuring proper handling of social media links. ## Changes - Modified `/packages/twenty-front/src/utils/checkUrlType.ts` - Added a check to prepend "https://" if URL doesn't start with a protocol --------- Co-authored-by: Prince Yadav Co-authored-by: Félix Malfait --- .../ui/field/display/components/LinkDisplay.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/twenty-front/src/modules/ui/field/display/components/LinkDisplay.tsx b/packages/twenty-front/src/modules/ui/field/display/components/LinkDisplay.tsx index e966fd1cd..9e2e2b48e 100644 --- a/packages/twenty-front/src/modules/ui/field/display/components/LinkDisplay.tsx +++ b/packages/twenty-front/src/modules/ui/field/display/components/LinkDisplay.tsx @@ -18,6 +18,12 @@ export const LinkDisplay = ({ value }: LinkDisplayProps) => { return <>; } + const absoluteUrl = url + ? url.startsWith('http') + ? url + : 'https://' + url + : ''; + const displayedValue = isNonEmptyString(value?.label) ? value?.label : url?.replace(/^http[s]?:\/\/(?:[w]+\.)?/gm, '').replace(/^[w]+\./gm, ''); @@ -29,8 +35,8 @@ export const LinkDisplay = ({ value }: LinkDisplayProps) => { : LinkType.Url; if (type === LinkType.LinkedIn || type === LinkType.Twitter) { - return ; + return ; } - return ; + return ; };