Is your feature request related to a problem? Please describe.
The existing routing mechanism in Neo.controller.Base had limitations in handling nested URL paths and resolving conflicts between overlapping routes. Specifically:
- The
{*paramName} wildcard in route definitions did not correctly capture path segments containing slashes, leading to itemId parameters being undefined for nested routes (e.g., /learn/gettingstarted/Workspaces).
- The route matching logic in
onHashChange followed a "first match wins" approach, which caused less specific routes (e.g., /learn) to be prioritized over more specific ones (e.g., /learn/{*itemId}), even when a more detailed match was available.
Describe the solution you'd like
The routing system has been enhanced to provide more robust and intuitive behavior for complex URL structures. The key improvements are:
- Correct Wildcard Parsing: The
{*paramName} and {...paramName} syntaxes now correctly capture entire nested path segments, including slashes, making them suitable for hierarchical content navigation.
- Specificity-Based Route Matching: The
onHashChange method now intelligently selects the most specific matching route. This prioritization is based on:
- The length of the matched URL segment (longer matches are preferred).
- The number of slashes in the route pattern (more slashes indicate deeper nesting and higher specificity).
- Improved Documentation: The
src/controller/Base.mjs file has been updated with intent-driven comments and examples to clearly explain the enhanced routing capabilities and their usage.
Describe alternatives you've considered
Manually parsing the URL hash within individual route handlers was a cumbersome alternative, but it lacked the declarative and robust nature of a framework-level routing solution.
Additional context
These changes significantly improve the flexibility and predictability of routing within Neo.mjs applications, particularly for applications with deep navigation structures like documentation or content management systems. For example, a route like '/learn/{*itemId}': 'onRouteLearnItem' can now effectively handle nested paths.
Modified Files:
src/controller/Base.mjs: Core routing logic and documentation updates.
apps/portal/view/learn/MainContainerController.mjs: '/learn/{*itemId}'
apps/portal/view/learn/ViewportController.mjs: '/learn/{*itemId}'
Is your feature request related to a problem? Please describe.
The existing routing mechanism in
Neo.controller.Basehad limitations in handling nested URL paths and resolving conflicts between overlapping routes. Specifically:{*paramName}wildcard in route definitions did not correctly capture path segments containing slashes, leading toitemIdparameters beingundefinedfor nested routes (e.g.,/learn/gettingstarted/Workspaces).onHashChangefollowed a "first match wins" approach, which caused less specific routes (e.g.,/learn) to be prioritized over more specific ones (e.g.,/learn/{*itemId}), even when a more detailed match was available.Describe the solution you'd like
The routing system has been enhanced to provide more robust and intuitive behavior for complex URL structures. The key improvements are:
{*paramName}and{...paramName}syntaxes now correctly capture entire nested path segments, including slashes, making them suitable for hierarchical content navigation.onHashChangemethod now intelligently selects the most specific matching route. This prioritization is based on:src/controller/Base.mjsfile has been updated with intent-driven comments and examples to clearly explain the enhanced routing capabilities and their usage.Describe alternatives you've considered
Manually parsing the URL hash within individual route handlers was a cumbersome alternative, but it lacked the declarative and robust nature of a framework-level routing solution.
Additional context
These changes significantly improve the flexibility and predictability of routing within Neo.mjs applications, particularly for applications with deep navigation structures like documentation or content management systems. For example, a route like
'/learn/{*itemId}': 'onRouteLearnItem'can now effectively handle nested paths.Modified Files:
src/controller/Base.mjs: Core routing logic and documentation updates.apps/portal/view/learn/MainContainerController.mjs:'/learn/{*itemId}'apps/portal/view/learn/ViewportController.mjs:'/learn/{*itemId}'