stats: bare theme URLs (/stats/jobs) open the core selection
All checks were successful
Deploy production / deploy (push) Successful in 1m20s

This commit is contained in:
2026-10-26 18:10:12 +00:00
parent b566a1244f
commit 4ef75f9d25

View File

@@ -1,11 +1,14 @@
import { error, redirect } from '@sveltejs/kit';
import { LEGACY, parsePlaces, statsHref } from '#lib/stats/matrix.js';
import { LEGACY, THEME_BY_SLUG, parsePlaces, statsHref } from '#lib/stats/matrix.js';
import type { RequestHandler } from './$types';
// /stats/<place> → its overview; the old section URLs (/stats/economy, …) move permanently.
export const GET: RequestHandler = ({ params, url }) => {
const legacy = LEGACY[params.place.toLowerCase()];
if (legacy) redirect(301, `${legacy}${url.search}`);
// A bare theme (/stats/jobs) opens it for the default selection.
if (THEME_BY_SLUG.has(params.place.toLowerCase()))
redirect(307, `${statsHref('core', params.place.toLowerCase())}${url.search}`);
const sel = parsePlaces(params.place);
if (!sel) error(404, 'Not Found');
redirect(307, `${statsHref(sel.slug, 'overview')}${url.search}`);