Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const { report, section, sectionKey, title } = Astro.props;
<Layout
title={`${title} — ${report.repo} codebase unpack`}
description={`${title} for ${report.repo}: claim-cited analysis at commit ${report.commit.sha.slice(0, 7)}, generated by CodeVetter Repo Unpack.`}
path={`/unpack/${report.slug}/${sectionKey}`}
path={`/unpack/${report.slug}/${Astro.params.section}`}
>
<main class="report">
<a class="back" href={`/unpack/${report.slug}`}>← {report.repo}</a>
Expand Down
13 changes: 13 additions & 0 deletions apps/landing-page-astro/worker.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,19 @@ export default {
const url = new URL(request.url);
const pathname = url.pathname;

// Older Repo Unpack canonicals used underscored section keys, while the
// generated routes use hyphens. Redirect only when the target exists.
const legacySection =
(request.method === 'GET' || request.method === 'HEAD') &&
pathname.match(/^\/unpack\/[^/]+\/([^/]*_[^/]*)$/);
if (legacySection) {
const target = new URL(url);
target.pathname =
pathname.slice(0, -legacySection[1].length) + legacySection[1].replaceAll('_', '-');
const targetResponse = await env.ASSETS.fetch(new Request(target, { method: 'HEAD' }));
if (targetResponse.ok) return Response.redirect(target, 301);
}

// /openapi.json — serve the spec directly.
if (pathname === '/openapi.json' || pathname === '/openapi.yaml') {
return serveOpenApiSpec();
Expand Down
Loading