fix(presentation): platform routes ignore unknown query parameters (Q-6.8-13a)

D-16. The platform `none` codec strips unknown keys instead of rejecting
them, so `/?utm_source=x` or an OAuth callback parameter no longer renders
"invalid address". The canonical redirect keeps the query of a route whose
search codec is `none`, so the URL itself is not rewritten.

router.test.tsx used `/examples/ui?unexpected=1` as its invalid-address
case, which encoded the old behavior; it now uses the reference list with
`?limit=invalid`. New router case (RED before the change) checks the page
renders and the URL keeps `?utm_source=mail`; lane gates pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
DongHyeonka
2026-09-24 13:44:38 +09:00
co-authored by Claude Opus 5.5
parent 22d4e8a29d
commit 11eb0dc0e0
3 changed files with 35 additions and 5 deletions
+7 -1
View File
@@ -21,6 +21,7 @@ import {
getRoute,
ROUTE_FEATURE_OWNER,
ROUTE_REGISTRY,
ROUTE_RUNTIME_CONTRACT,
} from "../../features/installed-feature-contracts.ts";
import {
PLATFORM_ROUTE_REGISTRY,
@@ -191,10 +192,15 @@ function CanonicalRouteRedirect({
useEffect(() => {
if (input.routeId === "NOT_FOUND") return;
const source = `${location.pathname}${location.search}`;
const target = buildRouteUrl(input.routeId, {
const canonical = buildRouteUrl(input.routeId, {
params: input.params,
search: input.search,
});
// D-16: a route that ignores its query leaves the query in the URL.
const target =
ROUTE_RUNTIME_CONTRACT[input.routeId].searchCodec === "none"
? `${canonical}${location.search}`
: canonical;
if (source === target) {
guard.current.reset();
} else if (guard.current.allow(source, target)) {
@@ -1,6 +1,8 @@
import { z } from "zod";
export const PLATFORM_ROUTE_CODECS = {
none: z.object({}).strict(),
// D-16: a route without input ignores unknown keys (`?utm_source=`, OAuth
// callback parameters) instead of calling the address invalid.
none: z.object({}),
NotFoundSplat: z.object({ "*": z.string().optional() }).strict(),
} as const;