summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJason Kim <git@jasonk.me>2021-04-22 22:43:30 -0700
committerJason Kim <git@jasonk.me>2021-04-22 23:00:09 -0700
commit21ee6b8542af700dc3d81520c7e62bc2657cb2af (patch)
tree9f728e96ca2a4124420ff70e16bb498e1d612c42 /src
parentbb6894cec54f746d76d8209ca25198881cf9d29b (diff)
downloadprivacy-redirect-21ee6b8542af700dc3d81520c7e62bc2657cb2af.tar.gz
privacy-redirect-21ee6b8542af700dc3d81520c7e62bc2657cb2af.tar.bz2
privacy-redirect-21ee6b8542af700dc3d81520c7e62bc2657cb2af.zip
fix: add "/comments" prefix only if it's missing
Although I have never seen it in the wild, it is possible to navigate to "redd.it/comments/...". This should redirect to "teddit.net/comments/..." in the case of instance teddit.net. However, the current code redirects it to "teddit.net/comments/comments/...". Fix it by avoiding adding the prefix if it's already there.
Diffstat (limited to 'src')
-rw-r--r--src/pages/background/background.js12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/pages/background/background.js b/src/pages/background/background.js
index 82f65a2..d3ec06c 100644
--- a/src/pages/background/background.js
+++ b/src/pages/background/background.js
@@ -483,9 +483,15 @@ function redirectReddit(url, initiator, type) {
return null;
}
} else if (url.host === "redd.it") {
- if (redditInstance.includes("teddit")) {
- // As of 2021-04-22, redirects for teddit redd.it links don't work out of
- // the box. Prefixing the path with "/comments" seems to help.
+ if (
+ redditInstance.includes("teddit") &&
+ !url.pathname.startsWith("/comments/")
+ ) {
+ // As of 2021-04-22, redirects for teddit redd.it links don't work unless
+ // the path starts with "/comments". It appears that all links that
+ // don't start with "/comments" are interchangeable with the ones
+ // that do start with "/comments", so manually add that prefix if it is
+ // missing.
return `${redditInstance}/comments${url.pathname}${url.search}`;
}
}
d>SimonBrazell 2021-01-10Restructure code with helper modules, add search engine settings, & advanced ...SimonBrazell 2021-01-05Added more instances of teddit and libredditSoheb 2021-01-05Add support for libredd.itSoheb 2020-12-26Losslessly compress PNG imagesFrank3K 2020-12-17add nitter.unixfox.eu as a nitter instance to the listEmilien Devos 2020-11-29Update background.jsAustin Huang 2020-11-22Updated background.jsaapl-yumi 2020-11-17Add "yewtu.be" back to the random instance listÉmilien Devos 2020-11-11Update background.jsYumi Izumi 2020-11-09Update Russian translationTotalCaesar659 2020-11-09Update README.mdYumi Izumi 2020-11-09Update options.jsYumi Izumi 2020-11-09Update options.htmlYumi Izumi 2020-11-08Update popup.jsYumi Izumi 2020-11-08Update popup.htmlYumi Izumi 2020-11-08Update background.jsYumi Izumi 2020-11-08Closes #111 - Adds ability to customise random instance poolsv1.1.43SimonBrazell 2020-11-08Fixes #119 - Change zh-CN to zh_CN.SimonBrazell 2020-11-07Update README.mdKunio 2020-11-05Update Russian translationTotalCaesar659 2020-11-04Update store listing templatesSimonBrazell 2020-11-04Update Bibliogram linksbopol 2020-11-04Remove duplicate entry in instagramReservedPaths arraySimonBrazell 2020-11-04Remove "https://yewtu.be" from random instance listSimonBrazell 2020-11-04Ignore embedded videos for FreeTube redirectsSimonBrazell 2020-11-04Fixes #99 - Bibliogram, handle /igtv/, /tv/ and /reel/v1.1.42SimonBrazell 2020-11-04Fixes #104 - /remove-twitter-sw.js stopping Twitter redirectsSimonBrazell 2020-11-04Closes #113 - Added support for FreeTubeSimonBrazell 2020-11-04Clean up invidious random instance listSimonBrazell 2020-10-23Rename _locales/store.md to _locales/pl/store.mdAustin Huang