Skip to content

fix(routing): accept a query or hash after a built route URL - #896

Open
0froq wants to merge 1 commit into
voidzero-dev:mainfrom
0froq:fix/route-url-query-suffix
Open

0froq wants to merge 1 commit into
voidzero-dev:mainfrom
0froq:fix/route-url-query-suffix

Conversation

@0froq

@0froq 0froq commented Nov 22, 2026

Copy link
Copy Markdown
Collaborator

This description was drafted by an agent from the diff and the commands it ran.

Fixes #893

Description

RouteUrl accepted a query or hash suffix only after a route path, so appending ?page=2 to a routeUrl() result dropped out of RouteUrl. router.visit(), Link, and props typed RouteUrl rejected it, and Void 1.9.1 accepted the same code.

The suffix now applies to a shared base, BuiltRouteUrl | RoutePathUrl, in the runtime type and in the declaration void prepare writes. Both spellings of a route URL take the same suffix, so the union has one place to change.

A suffix on a routeUrl() result that already carries query or hash still type-checks, as in the issue's ${routeUrl('/a', { query: { a: 1 } })}?b=2. BuiltRouteUrl is opaque, so telling that apart needs a second brand. Route path strings already allow the same join.

Test

The typed fixture in route-url-builder.test.ts now appends a query and a hash to a RouteUrl, to a routeUrl() result, and passes both to router.visit(). It also pins that a suffix does not skip the route check (/unknown?page=2) and that it needs its own separator.

With the same fixture on the base types:

check-typed.ts(58,7): error TS2322: Type '... | `${BuiltRouteUrl}?page=2` | ...' is not assignable to type ...
  Type '`${BuiltRouteUrl}?page=2`' is not assignable to type ...
check-typed.ts(68,19): error TS2345: Argument of type '... | `${BuiltRouteUrl}?page=2` | ...' is not assignable to parameter of type 'RouteUrlInput'.

`RouteUrl` allowed a suffix only after a route path, so adding `?page=2` to
a `routeUrl()` result failed the type check. Apply the suffix to a shared
base instead, in both the runtime and the generated declaration.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A routeUrl() result with a query appended isn't a RouteUrl

1 participant