summaryrefslogtreecommitdiff
path: root/workers/branch/src/index.ts
diff options
context:
space:
mode:
authorYuriy Andamasov <yuriy@vyos.io>2026-07-22 16:11:16 +0300
committerYuriy Andamasov <yuriy@vyos.io>2026-07-22 16:11:16 +0300
commitf1fc5d8d45242c3b259ce216c0705e828a51fb2a (patch)
treeb801641bf8d502254f3d4e8b9005e9c84dcedf96 /workers/branch/src/index.ts
parentcce3f36602e285a13efe02bf8906f871f04c5ada (diff)
downloadvyos-documentation-claude/html-handling-parity.tar.gz
vyos-documentation-claude/html-handling-parity.zip
workers: html_handling none + worker index-mapping — RTD .html URL parity (smoke 307 fix)claude/html-handling-parity
Diffstat (limited to 'workers/branch/src/index.ts')
-rw-r--r--workers/branch/src/index.ts11
1 files changed, 10 insertions, 1 deletions
diff --git a/workers/branch/src/index.ts b/workers/branch/src/index.ts
index d955d166..e9342c26 100644
--- a/workers/branch/src/index.ts
+++ b/workers/branch/src/index.ts
@@ -38,7 +38,16 @@ export function withDocsHeaders(
export default {
async fetch(request: Request, env: Env): Promise<Response> {
const url = new URL(request.url);
- const resp = await env.ASSETS.fetch(request);
+ // With assets html_handling "none", the runtime serves explicit .html URLs directly
+ // but does NOT map a directory URL ("/foo/") to its index.html — the worker must map
+ // trailing-slash URLs to index.html itself to preserve ReadTheDocs URL parity.
+ let assetRequest = request;
+ if (url.pathname.endsWith("/")) {
+ const mapped = new URL(url);
+ mapped.pathname = url.pathname + "index.html";
+ assetRequest = new Request(mapped, request);
+ }
+ const resp = await env.ASSETS.fetch(assetRequest);
return withDocsHeaders(resp, url.pathname, env);
},
} satisfies ExportedHandler<Env>;