Safe Link: Fix opening search-highlighted links (#2368)
This commit is contained in:
parent
ec2a4431be
commit
23ce8f0927
@ -29,10 +29,11 @@ const SafeLink: FC<OwnProps> = ({
|
|||||||
const { openUrl } = getActions();
|
const { openUrl } = getActions();
|
||||||
|
|
||||||
const content = children || text;
|
const content = children || text;
|
||||||
const isSafe = url === content;
|
const isSafe = url === text;
|
||||||
|
|
||||||
const handleClick = useCallback((e: React.MouseEvent<HTMLAnchorElement, MouseEvent>) => {
|
const handleClick = useCallback((e: React.MouseEvent<HTMLAnchorElement, MouseEvent>) => {
|
||||||
if (!url) return true;
|
if (!url) return true;
|
||||||
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
openUrl({ url, shouldSkipModal: isSafe });
|
openUrl({ url, shouldSkipModal: isSafe });
|
||||||
|
|
||||||
|
|||||||
@ -84,6 +84,8 @@ const WebLink: FC<OwnProps> = ({
|
|||||||
(!photo && !video) && 'without-media',
|
(!photo && !video) && 'without-media',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const safeLinkContent = url.replace('mailto:', '') || displayUrl;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={className}
|
className={className}
|
||||||
@ -105,11 +107,9 @@ const WebLink: FC<OwnProps> = ({
|
|||||||
<SafeLink
|
<SafeLink
|
||||||
url={url}
|
url={url}
|
||||||
className="site-name"
|
className="site-name"
|
||||||
text=""
|
text={safeLinkContent}
|
||||||
isRtl={lang.isRtl}
|
isRtl={lang.isRtl}
|
||||||
>
|
/>
|
||||||
{url.replace('mailto:', '') || displayUrl}
|
|
||||||
</SafeLink>
|
|
||||||
{senderTitle && <div className="sender-name">{renderText(senderTitle)}</div>}
|
{senderTitle && <div className="sender-name">{renderText(senderTitle)}</div>}
|
||||||
</div>
|
</div>
|
||||||
{senderTitle && (
|
{senderTitle && (
|
||||||
|
|||||||
@ -131,11 +131,9 @@ const Checkout: FC<OwnProps> = ({
|
|||||||
{langStringSplit[0]}
|
{langStringSplit[0]}
|
||||||
<SafeLink
|
<SafeLink
|
||||||
url={url}
|
url={url}
|
||||||
text=""
|
text={langStringSplit[1]}
|
||||||
isRtl={isRtl}
|
isRtl={isRtl}
|
||||||
>
|
/>
|
||||||
{langStringSplit[1]}
|
|
||||||
</SafeLink>
|
|
||||||
{langStringSplit.slice(2)}
|
{langStringSplit.slice(2)}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user