pages: apex redirects /<dir>/ only for venture pages (dir has index.html); asset folders and .well-known stay on the apex
Fixes the shot of a venture whose subdomain is not ours (aicharts.yolopreneur.lol is a Worker) and the NIP-05 path at the apex. Also: HEAD flag no longer shadowed by the path segment (that bug emptied every GET body). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CYHXFvWMCs1GUmRmpySqQ6
This commit is contained in:
1 parent
17a36cd1b6
commit
e4937e3c7f
1 file changed
+4
-3
+4
-3
@@ -126,9 +126,10 @@ class Handler(http.server.BaseHTTPRequestHandler):
|
||||
root = site_root(repo).resolve()
|
||||
rel = unquote(path).lstrip("/")
|
||||
# on a wildcard zone's apex, /<sub>/... lives at <sub>.zone: send people there
|
||||
head = rel.split("/", 1)[0]
|
||||
if not sub and self.host() in WILDCARDS and head and (root / head).is_dir() and ".." not in rel:
|
||||
self.send_response(301); self.send_header("location", f"https://{head}.{self.host()}/" + rel[len(head):].lstrip("/")); self.end_headers()
|
||||
first = rel.split("/", 1)[0]
|
||||
# only folders that are a venture page (have an index.html); assets folders, .well-known etc. stay on the apex
|
||||
if not sub and self.host() in WILDCARDS and first and (root / first / "index.html").is_file() and ".." not in rel:
|
||||
self.send_response(301); self.send_header("location", f"https://{first}.{self.host()}/" + rel[len(first):].lstrip("/")); self.end_headers()
|
||||
return
|
||||
if sub:
|
||||
root = (root / sub).resolve()
|
||||
|
||||
Reference in new issue
Block a user