Fix: Serve promoted images with a + without redirecting

Rule conditions see the original path, so chained rules can't encode +s. One
rule per number of +s does it instead, which only fits the free plan's 10
rules if they're shared by all sites, so static files now live under their
hostname (/free.direct-img.link/1/orange%2Bcat).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-26 18:11:59 +00:00
co-authored by Claude Opus 5.5
parent b932044c5f
commit d2f8c8ffba
8 changed files with 44 additions and 43 deletions
+2 -3
View File
@@ -13,9 +13,8 @@ export const MAX_INDEX = { "": 40, free: 20, ai: 1000 };
// "free", "ai" or "" (main site), from the hostname's first label
export const siteOf = hostname => ["free", "ai"].find(s => hostname.startsWith(`${s}.`)) || "";
// Path prefix each site's ?i= is folded into by the zone's URL Rewrite and Redirect Rules (scripts/rules.js), e.g.
// /orange+cat?i=2 → /web/2/orange+cat, so promoted images can be static files, which ignore query strings
export const folder = site => site || "web";
// Most +s in a query the zone's URL Rewrite Rules (scripts/rules.js) can turn into a static file's path, one rule each
export const MAX_PLUSES = 7;
export function normalizeQuery(path) {
const clean = s => s.toLowerCase().trim().replace(/[\x00-\x1f]/g, "").replace(/\/+$/, "").replace(/\s+/g, " ");