You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add a segment-aware prefix matching mode to Template #1564
Template.MODE_STARTS_WITH matches characters, not URI path segments. When routers or applications are mounted under path prefixes on one connector, a route attached to /mcp also matches /mcpx and /mcp-admin/tools:
router.attach("/mcp", mcpRouter); // Router target => MODE_STARTS_WITHrouter.attach("/mcp-admin", adminRouter);
// GET /mcpx -> mcpRouter, remaining part "x"// GET /mcp-admin/tools -> mcpRouter (first match), remaining part "-admin/tools"
MODE_BEST_MATCH fixes the /mcp-admin case but not /mcpx. Combining MODE_EQUALS on /mcp with MODE_STARTS_WITH on /mcp/ gets the boundaries right but consumes the leading /, so the mounted router sees tools instead of /tools. Today the only full fix is a TemplateRoute subclass overriding score().
Proposal
Add a third matching mode, Template.MODE_STARTS_WITH_SEGMENT: like MODE_STARTS_WITH, but the match must end on a segment boundary, meaning the end of the string, a following /, ?, ; or #, or a match that itself ends with /. An empty template still matches anything.
Existing modes are unchanged, so this is opt-in and non-breaking.
Open question
Should Router.getMatchingMode() later default to this mode for Router and Directory targets (and VirtualHost)? That changes behaviour for existing applications, so it seems better suited to a later major version than to 3.0.
Context
Ikanos (Naftiko) plans to serve its REST, MCP and Skill adapters on one connector, routed by path prefix and by VirtualHost.
Fixed by #1565: Template.MODE_STARTS_WITH_SEGMENT matches a prefix only on a segment boundary (end of string, /, ?, ; or #, or a match ending with /), keeping the leading / in the remaining part, with Template and Router tests.
Activity
jlouvel commentedon Nov 5, 2026
Fixed by #1565:
Template.MODE_STARTS_WITH_SEGMENTmatches a prefix only on a segment boundary (end of string,/,?,;or#, or a match ending with/), keeping the leading/in the remaining part, withTemplateandRoutertests.🤖 Generated with Claude Code