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

This commit is contained in:
stan committed 2026-10-26 18:10:12 +00:00
1 parent b566a1244f
commit 4ef75f9d25
1 file changed
+4 -1
+4 -1
View File
@@ -1,11 +1,14 @@
import { error, redirect } from '@sveltejs/kit'; 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'; import type { RequestHandler } from './$types';
// /stats/<place> → its overview; the old section URLs (/stats/economy, …) move permanently. // /stats/<place> → its overview; the old section URLs (/stats/economy, …) move permanently.
export const GET: RequestHandler = ({ params, url }) => { export const GET: RequestHandler = ({ params, url }) => {
const legacy = LEGACY[params.place.toLowerCase()]; const legacy = LEGACY[params.place.toLowerCase()];
if (legacy) redirect(301, `${legacy}${url.search}`); 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); const sel = parsePlaces(params.place);
if (!sel) error(404, 'Not Found'); if (!sel) error(404, 'Not Found');
redirect(307, `${statsHref(sel.slug, 'overview')}${url.search}`); redirect(307, `${statsHref(sel.slug, 'overview')}${url.search}`);