diff options
author | Brian <18603393+brian6932@users.noreply.github.com> | 2023-02-06 01:59:40 -0500 |
---|---|---|
committer | Brian <18603393+brian6932@users.noreply.github.com> | 2023-02-06 01:59:40 -0500 |
commit | 617b0da8840e2ffb8c19cc339ff90048c9c7ec15 (patch) | |
tree | 53797c34bec5d2428b8fb5b56dac711221664957 /src/assets/javascripts/services.js | |
parent | Merge pull request #618 from kirizdev/master (diff) | |
download | libredirect-617b0da8840e2ffb8c19cc339ff90048c9c7ec15.zip |
services: Fix `anonymousOverflow` redirect
Diffstat (limited to 'src/assets/javascripts/services.js')
-rw-r--r-- | src/assets/javascripts/services.js | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/assets/javascripts/services.js b/src/assets/javascripts/services.js index 6e2eca13..0aac546d 100644 --- a/src/assets/javascripts/services.js +++ b/src/assets/javascripts/services.js @@ -367,7 +367,7 @@ function redirect(url, type, initiator, forceRedirection) { if (url.hostname.match(/^[a-zA-Z0-9-]+\.(?:fandom|wikia)\.com/)) { wiki = url.hostname.match(/^[a-zA-Z0-9-]+(?=\.(?:fandom|wikia)\.com)/) if (wiki == "www" || !wiki) wiki = "" - else wiki = `/${wiki}`; + else wiki = `/${wiki}` urlpath = url.pathname } else { wiki = url.pathname.match(/(?<=wiki\/w:c:)[a-zA-Z0-9-]+(?=:)/) @@ -406,9 +406,9 @@ function redirect(url, type, initiator, forceRedirection) { case "neuters": { const p = url.pathname if (p.startsWith('/article/') || p.startsWith('/pf/') || p.startsWith('/arc/') || p.startsWith('/resizer/')) { - return null; + return null } - return `${randomInstance}${p}`; + return `${randomInstance}${p}` } case "dumb": { if (url.pathname.endsWith('-lyrics')) return `${randomInstance}${url.pathname}` @@ -419,7 +419,8 @@ function redirect(url, type, initiator, forceRedirection) { } case "anonymousOverflow": { if (!url.pathname.startsWith('/questions') && url.pathname != '/') return - return `${randomInstance}${url.pathname}${url.search}` + const threadID = /\/\d+(?=[?&#/]|$)/.exec(url.pathname)?.[0] + return `${randomInstance}${threadID ? '/questions' + threadID : url.pathname}${url.search}` } case "biblioReads": { if (!url.pathname.startsWith('/book/show/') && url.pathname != '/') return |