diff --git a/src/plugins/fs_routes/mod_test.tsx b/src/plugins/fs_routes/mod_test.tsx index a5b2208c..9cbd0d7c 100644 --- a/src/plugins/fs_routes/mod_test.tsx +++ b/src/plugins/fs_routes/mod_test.tsx @@ -1150,3 +1150,25 @@ Deno.test("fsRoutes - default GET route doesn't override existing handler", asyn "

true

", ); }); + +Deno.test("support numeric keys", async () => { + const TestComponent = () =>
foo
; + + const server = await createServer({ + "routes/index.tsx": { + default: () => { + return ( + <> + + + ok + + ); + }, + }, + }); + + const res = await server.get("/"); + const text = await res.text(); + expect(text).toContain("ok"); +}); diff --git a/src/runtime/server/preact_hooks.tsx b/src/runtime/server/preact_hooks.tsx index 687a37a5..fc4bd2a4 100644 --- a/src/runtime/server/preact_hooks.tsx +++ b/src/runtime/server/preact_hooks.tsx @@ -165,8 +165,11 @@ options[OptionsType.ATTR] = (name, value) => { const PATCHED = new WeakSet(); -function normalizeKey(str: string) { - return str.replaceAll(":", "_"); +function normalizeKey(key: string | number) { + if (typeof key === "number") { + key = key.toString(); + } + return key.replaceAll(":", "_"); } const oldDiff = options[OptionsType.DIFF];