Route matching order limits with Mithril wildcard patterns
0 reputation · 03 Feb 2020, 10:06 UTC
Mithril's router maps URL paths to components using an order-dependent pattern-matching system. More specific patterns must be defined before generic ones; otherwise, a wildcard route placed earlier will match first and prevent the specific route from resolving. This ordering constraint becomes a practical limit when route definitions are composed dynamically or split across modules.
If two route tables are merged without preserving priority, a generic pattern may shadow a more specific one. The router does not provide a built-in priority mechanism or conflict detection to warn developers of unreachable routes. In large single-page applications, this can lead to silent failures where a route silently falls back to a catch-all handler.
Is there a documented way to assign explicit priority to Mithril routes independent of definition order? When composing route tables from separate modules, what strategies ensure that specific patterns are not shadowed by wildcards? Does the router expose any diagnostic or warning when a route becomes unreachable due to an earlier generic match?