Fix nomadro.live ads.txt always served (ignore zh cookie)

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
eric
2026-08-25 06:34:49 -05:00
parent c60fdf0fd4
commit acc0a81ab9
3 changed files with 14 additions and 1 deletions

View File

@@ -34,6 +34,8 @@ const BOT_RE =
const WP_PATH_RE =
/^\/(wp-admin|wp-login\.php|wp-cron\.php|wp-comments-post\.php|xmlrpc\.php|wp-json|wp-content|wp-includes)(\/|$)/i;
const ALWAYS_WP_RE = /^\/(ads\.txt|robots\.txt)(\/|$|\?)/i;
function getCookie(req, name) {
const raw = req.headers.cookie || "";
for (const p of raw.split(/;\s*/)) {
@@ -118,6 +120,7 @@ function resolveTarget(req) {
const url = req.url || "/";
const path = url.split("?")[0];
if (ALWAYS_WP_RE.test(path) || path === "/ads.txt" || path === "/robots.txt") return WP;
if (WP_PATH_RE.test(path)) return WP;
if (isBot(req)) return WP;
if (url.includes("noscript=1")) return WP;