redirect *.meta.stackexchange.com

This commit is contained in:
DokterKaj 2024-10-13 13:02:49 +08:00 committed by GitHub
parent bef9c148a1
commit 6e5a0f1f41
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 1 deletions

View File

@ -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}`
}