summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJason Kim <git@jasonk.me>2021-04-22 22:54:00 -0700
committerJason Kim <git@jasonk.me>2021-04-22 23:01:54 -0700
commite3df6c4333c107240a45d6fbad933b54caa11139 (patch)
treeb393b2ab19453a54dc1aa5a2dc0d072660c57b82 /src
parent21ee6b8542af700dc3d81520c7e62bc2657cb2af (diff)
downloadprivacy-redirect-e3df6c4333c107240a45d6fbad933b54caa11139.tar.gz
privacy-redirect-e3df6c4333c107240a45d6fbad933b54caa11139.tar.bz2
privacy-redirect-e3df6c4333c107240a45d6fbad933b54caa11139.zip
fix: add comments prefix if no nested path
The previous fix failed to consider links like "redd.it/r/.../comments/...". Those don't really exist in the wild, and they don't work (when redirects are turned off). Still, play it safe and don't add "/comments" prefix unless the path has height 1. Now, redirects should work for - redd.it/foo - redd.it/comments/foo - redd.it/r/bar/comments/foo even though the only kind of native link that works is - redd.it/foo
Diffstat (limited to 'src')
-rw-r--r--src/pages/background/background.js2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/pages/background/background.js b/src/pages/background/background.js
index d3ec06c..fd0d55a 100644
--- a/src/pages/background/background.js
+++ b/src/pages/background/background.js
@@ -485,7 +485,7 @@ function redirectReddit(url, initiator, type) {
} else if (url.host === "redd.it") {
if (
redditInstance.includes("teddit") &&
- !url.pathname.startsWith("/comments/")
+ !url.pathname.match(/^\/\S+\//)
) {
// 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