stats: bare theme URLs (/stats/jobs) open the core selection
All checks were successful
Deploy production / deploy (push) Successful in 1m20s
All checks were successful
Deploy production / deploy (push) Successful in 1m20s
This commit is contained in:
@@ -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}`);
|
||||||
|
|||||||
Reference in New Issue
Block a user