From 617b0da8840e2ffb8c19cc339ff90048c9c7ec15 Mon Sep 17 00:00:00 2001 From: Brian <18603393+brian6932@users.noreply.github.com> Date: Mon, 6 Feb 2023 01:59:40 -0500 Subject: [PATCH] services: Fix `anonymousOverflow` redirect --- src/assets/javascripts/services.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/assets/javascripts/services.js b/src/assets/javascripts/services.js index 6e2eca1..0aac546 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