fix: adding https in checkurltype (#6295)
# 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 <prince1.yadav@tataaig.com> Co-authored-by: Félix Malfait <felix.malfait@gmail.com>
This commit is contained in:
@ -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 <SocialLink href={url} type={type} label={displayedValue} />;
|
||||
return <SocialLink href={absoluteUrl} type={type} label={displayedValue} />;
|
||||
}
|
||||
|
||||
return <RoundedLink href={url} label={displayedValue} />;
|
||||
return <RoundedLink href={absoluteUrl} label={displayedValue} />;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user