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.
This commit is contained in:
parent
bb6894cec5
commit
21ee6b8542
|
@ -483,9 +483,15 @@ function redirectReddit(url, initiator, type) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
} else if (url.host === "redd.it") {
|
} else if (url.host === "redd.it") {
|
||||||
if (redditInstance.includes("teddit")) {
|
if (
|
||||||
// As of 2021-04-22, redirects for teddit redd.it links don't work out of
|
redditInstance.includes("teddit") &&
|
||||||
// the box. Prefixing the path with "/comments" seems to help.
|
!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}`;
|
return `${redditInstance}/comments${url.pathname}${url.search}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue