about summary refs log tree commit diff stats
path: root/src/pages/background
diff options
context:
space:
mode:
Diffstat (limited to 'src/pages/background')
-rw-r--r--src/pages/background/background.js15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/pages/background/background.js b/src/pages/background/background.js
index 87bc8dda..4fa36933 100644
--- a/src/pages/background/background.js
+++ b/src/pages/background/background.js
@@ -482,6 +482,21 @@ function redirectReddit(url, initiator, type) {
     } else {
       return null;
     }
+  } else if (url.host === "redd.it") {
+    if (
+      redditInstance.includes("teddit") &&
+      !url.pathname.match(/^\/+[^\/]+\/+[^\/]/)
+    ) {
+      // As of 2021-04-22, redirects for teddit redd.it/foo links don't work.
+      // It appears that adding "/comments" as a prefix works, so manually add
+      // that prefix if it is missing.  Even though redd.it/comments/foo links
+      // don't seem to work or exist, guard against affecting those kinds of
+      // paths.
+      //
+      // Note the difference between redd.it/comments/foo (doesn't work) and
+      // teddit.net/comments/foo (works).
+      return `${redditInstance}/comments${url.pathname}${url.search}`;
+    }
   }
   return `${redditInstance}${url.pathname}${url.search}`;
 }