dont open in a new tab for internal urls
This commit is contained in:
parent
e921d58f73
commit
b74dc804d6
1 changed files with 9 additions and 1 deletions
|
@ -145,11 +145,19 @@ const Button = forwardRef<any, {}>((props: Props, ref: any) => {
|
||||||
</span>
|
</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'))) {
|
if (href || (navigate && navigate.startsWith('http'))) {
|
||||||
// TODO: replace the below with an outbound link tracker for matomo
|
// TODO: replace the below with an outbound link tracker for matomo
|
||||||
return (
|
return (
|
||||||
<a
|
<a
|
||||||
target={meme ? '' : '_blank'}
|
target={meme && isAnInternalLink ? '' : '_blank'}
|
||||||
rel="noopener noreferrer"
|
rel="noopener noreferrer"
|
||||||
href={href || navigate}
|
href={href || navigate}
|
||||||
className={combinedClassName}
|
className={combinedClassName}
|
||||||
|
|
Loading…
Reference in a new issue