dont open in a new tab for internal urls

This commit is contained in:
Anthony 2022-03-24 19:27:09 +01:00 committed by Thomas Zarebczan
parent e921d58f73
commit b74dc804d6

View file

@ -145,11 +145,19 @@ const Button = forwardRef<any, {}>((props: Props, ref: any) => {
</span>
);
// check if the link is for odysee.com
function isAnOdyseeLink(urlString) {
return urlString.indexOf('https://odysee.com') !== -1 || urlString.indexOf('http://odysee.com') !== -1;
}
// if it's an internal link we won't open a new tab
const isAnInternalLink = (href || navigate) && (isAnOdyseeLink(href) || isAnOdyseeLink(navigate));
if (href || (navigate && navigate.startsWith('http'))) {
// TODO: replace the below with an outbound link tracker for matomo
return (
<a
target={meme ? '' : '_blank'}
target={meme && isAnInternalLink ? '' : '_blank'}
rel="noopener noreferrer"
href={href || navigate}
className={combinedClassName}