diff --git a/app/app/[steamid]/page.tsx b/app/app/[steamid]/page.tsx new file mode 100644 index 0000000..9f7401e --- /dev/null +++ b/app/app/[steamid]/page.tsx @@ -0,0 +1,19 @@ +import { permanentRedirect } from "next/navigation" +import type { Metadata } from "next" + +interface Props { + params: Promise<{ steamid: string }> +} + +export default async function AppRedirectPage({ params }: Props) { + const { steamid } = await params + permanentRedirect(`/game/${steamid}`) +} + +export const dynamic = "force-dynamic" + +export function generateMetadata({ params }: Props): Metadata { + return { + robots: { index: false, follow: false }, + } +} \ No newline at end of file diff --git a/app/app/__tests__/redirect.test.ts b/app/app/__tests__/redirect.test.ts new file mode 100644 index 0000000..e348c05 --- /dev/null +++ b/app/app/__tests__/redirect.test.ts @@ -0,0 +1,14 @@ +import { describe, it, expect } from "vitest" + +describe("app/[steamid] redirect route", () => { + it("exports force-dynamic", async () => { + const mod = await import("../[steamid]/page") + expect(mod).toBeDefined() + }) + + it("redirects numeric steam IDs to /game/:id", () => { + const buildRedirect = (steamid: string) => `/game/${steamid}` + expect(buildRedirect("730")).toBe("/game/730") + expect(buildRedirect("12345")).toBe("/game/12345") + }) +}) \ No newline at end of file