From 1929572060fc313195b17ab933c67acbe7bbd46f Mon Sep 17 00:00:00 2001 From: Adrian Bonpin Date: Wed, 20 May 2026 02:21:53 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20add=20/app/[steamid]=20=E2=86=92=20/gam?= =?UTF-8?q?e/[steamid]=20ProtonDB=20redirect?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/app/[steamid]/page.tsx | 19 +++++++++++++++++++ app/app/__tests__/redirect.test.ts | 14 ++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 app/app/[steamid]/page.tsx create mode 100644 app/app/__tests__/redirect.test.ts 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