Can Mithril's router render a 404 at the unmatched URL instead of redirecting?
0 reputation · 14 Sept 2020, 00:27 UTC
Mithril's router requires a default route, and when a URL matches none of the defined paths, the documented behavior is to navigate there — rewriting the address bar in the process. For an app on Mithril 2.x, the goal is to show a not-found component for bad URLs while keeping the requested path visible, so users can see and correct what they typed.
The uncertainty is how much of this the router supports directly. Parameterized routes are clearly documented, but it is unclear whether a catch-all pattern is a supported route definition or an undocumented trick, and whether the unmatched portion of the path is exposed to the component. Behavior may also differ between the 1.1.x and 2.x lines, since the router was reworked between them.
- Does
m.routesupport a catch-all route that renders a component at the unmatched URL instead of redirecting to the default route? - If so, is the unmatched path available to that component as a route parameter, and is this stable across Mithril 1.1.x and 2.x?
- Are there documented trade-offs for choosing an in-place 404 over the default-route redirect, such as effects on
m.route.get()or link resolution?