Merge pull request #1009 from DokterKaj/patch-1

redirect *.meta.stackexchange.com
This commit is contained in:
ManeraKai 2024-10-14 23:07:00 +03:00 committed by GitHub
commit 6f2ff60733
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 2 deletions

View File

@ -269,8 +269,11 @@ function rewrite(url, originUrl, frontend, randomInstance) {
// https://stackexchange.com or https://superuser.com // https://stackexchange.com or https://superuser.com
return `${randomInstance}${url.pathname}${url.search}` 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 && regex.length > 1) {
if (regex[2]) {
return `${randomInstance}/exchange/${url.hostname}${url.pathname}${url.search}`
}
const subdomain = regex[1] const subdomain = regex[1]
return `${randomInstance}/exchange/${subdomain}${url.pathname}${url.search}` return `${randomInstance}/exchange/${subdomain}${url.pathname}${url.search}`
} }

View File

@ -753,7 +753,7 @@
}, },
"targets": [ "targets": [
"^https?:\\/{2}(www\\.)?([a-zA-Z]+\\.)?stackoverflow\\.com\\/", "^https?:\\/{2}(www\\.)?([a-zA-Z]+\\.)?stackoverflow\\.com\\/",
"(?!^https?:\\/{2}(api|data|blog)\\.)^https?:\\/{2}([a-zA-Z0-9-]+\\.)stackexchange\\.com\\/", "^https?:\\/{2}((?!(api|data|blog)\\.)[a-zA-Z0-9-]+\\.(meta\\.)?)?stackexchange\\.com\\/",
"^https?:\\/{2}(www\\.)?([a-zA-Z]+\\.)?(askubuntu\\.com|mathoverflow\\.net|serverfault\\.com|stackapps\\.com|superuser\\.com)\\/" "^https?:\\/{2}(www\\.)?([a-zA-Z]+\\.)?(askubuntu\\.com|mathoverflow\\.net|serverfault\\.com|stackapps\\.com|superuser\\.com)\\/"
], ],
"name": "Stack Overflow", "name": "Stack Overflow",