From 166f9da2323d0be1e6f192f0b51b8d7b31f2d666 Mon Sep 17 00:00:00 2001
From: Lim Chee Aun <cheeaun@gmail.com>
Date: Tue, 16 May 2023 10:40:05 +0800
Subject: [PATCH] Prevent showing card and QP for links that link the post
 itself

Use case: links from lemmy
---
 src/components/status.jsx | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/components/status.jsx b/src/components/status.jsx
index 1b8a85d6..7f3c8590 100644
--- a/src/components/status.jsx
+++ b/src/components/status.jsx
@@ -965,7 +965,12 @@ function Status({
                         'a[href]:not(.u-url):not(.mention):not(.hashtag)',
                       ),
                     )
-                      .filter((a) => isMastodonLinkMaybe(a.href))
+                      .filter((a) => {
+                        const url = a.href;
+                        const isPostItself =
+                          url === status.url || url === status.uri;
+                        return !isPostItself && isMastodonLinkMaybe(url);
+                      })
                       .forEach((a, i) => {
                         unfurlMastodonLink(currentInstance, a.href).then(
                           (result) => {
@@ -1076,6 +1081,9 @@ function Status({
             </div>
           )}
           {!!card &&
+            card?.url !== status.url &&
+            card?.url !== status.uri &&
+            /^https/i.test(card?.url) &&
             !sensitive &&
             !spoilerText &&
             !poll &&