LearnNewsExamplesServices
Frontmatter
id7773
titleEnhance Router to provide `capturedRoute` in handler parameters
stateClosed
labels
enhancementai
assigneestobiu
createdAtNov 14, 2025, 3:25 PM
updatedAtNov 14, 2025, 4:01 PM
githubUrlhttps://github.com/neomjs/neo/issues/7773
authortobiu
commentsCount0
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtNov 14, 2025, 4:01 PM

Enhance Router to provide capturedRoute in handler parameters

Closed v11.3.0 enhancementai
tobiu
tobiu commented on Nov 14, 2025, 3:25 PM

The onHashChange method in src/controller/Base.mjs should be enhanced to provide more context to route handlers (handler, preHandler, defaultRoute).

Currently, handlers receive (params, value, oldValue). The value object, which comes from HashHistory, contains information about the hash change. This value object should be enhanced to include a capturedRoute property, which would be the string of the route pattern that was matched.

Acceptance Criteria:

  1. When a specific route is matched, the value object passed to its preHandler (if any) and handler should contain a capturedRoute property with the matching route key (e.g., /users/{userId}).
  2. When no specific route is matched and a defaultRoute is configured, the value object passed to the default handler should contain capturedRoute: 'default'.
  3. When no route is matched and no defaultRoute is configured, the value object passed to onNoRouteFound should contain capturedRoute: null.

This will allow handlers to have more context about which route pattern triggered them, which can be useful for analytics, logging, or dynamic behavior.

tobiu added the enhancement label on Nov 14, 2025, 3:25 PM
tobiu added the ai label on Nov 14, 2025, 3:25 PM
tobiu assigned to @tobiu on Nov 14, 2025, 3:27 PM
tobiu referenced in commit a1d3f9c - "Enhance Router to provide capturedRoute in handler parameters #7773" on Nov 14, 2025, 4:01 PM
tobiu closed this issue on Nov 14, 2025, 4:01 PM