From 6e5a0f1f41112d4dd4b3931dbd3407a8c7dad286 Mon Sep 17 00:00:00 2001 From: DokterKaj <54882101+DokterKaj@users.noreply.github.com> Date: Sun, 13 Oct 2024 13:02:49 +0800 Subject: [PATCH] redirect *.meta.stackexchange.com --- src/assets/javascripts/services.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/assets/javascripts/services.js b/src/assets/javascripts/services.js index 3609d6c..e85b5bf 100644 --- a/src/assets/javascripts/services.js +++ b/src/assets/javascripts/services.js @@ -269,8 +269,11 @@ function rewrite(url, originUrl, frontend, randomInstance) { // https://stackexchange.com or https://superuser.com return `${randomInstance}${url.pathname}${url.search}` } - const regex = url.href.match(/https?:\/{2}(?:([a-zA-Z0-9-]+)\.)?stackexchange\.com\//) + const regex = url.href.match(/https?:\/{2}(?:([a-zA-Z0-9-]+)\.(meta\.)?)?stackexchange\.com\//) if (regex && regex.length > 1) { + if (regex[2]) { + return `${randomInstance}/exchange/${url.hostname}${url.pathname}${url.search}` + } const subdomain = regex[1] return `${randomInstance}/exchange/${subdomain}${url.pathname}${url.search}` }