From 43f47acd8c3f6218309f1be3890d07ccf7b5066b Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Tue, 16 Jan 2024 20:05:27 +0100 Subject: [PATCH] Fix endless redirects in some circumstances Co-authored-by: Joshix-1 <57299889+Joshix-1@users.noreply.github.com> --- app/javascript/mastodon/components/status_content.jsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/javascript/mastodon/components/status_content.jsx b/app/javascript/mastodon/components/status_content.jsx index 8f79cb165d..ced324a10c 100644 --- a/app/javascript/mastodon/components/status_content.jsx +++ b/app/javascript/mastodon/components/status_content.jsx @@ -123,6 +123,11 @@ class StatusContent extends PureComponent { } else if (link.textContent[0] === '#' || (link.previousSibling && link.previousSibling.textContent && link.previousSibling.textContent[link.previousSibling.textContent.length - 1] === '#')) { link.addEventListener('click', this.onHashtagClick.bind(this, link.text), false); link.setAttribute('href', `/tags/${link.text.replace(/^#/, '')}`); + } else if (status.get('uri') === link.href) { + // the link points to the source of the status. this happens e.g. with lemmy posts. + // there is no use in trying to open the url on this instance as it's already opened. + link.setAttribute('title', link.href); + link.classList.add('unhandled-link'); } else { link.setAttribute('title', link.href); link.setAttribute('href', `/redirect?url=${encodeURIComponent(link.href)}`);