Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC for router enhancements #154

Closed
wants to merge 11 commits into from
8 changes: 6 additions & 2 deletions text/router-enhancements.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ Router.map(function() {
this.route('sample1', { path: '/foo/bar' });
this.route('sample2', { path: '/foo/(:param)' });
this.route('sample3', { path: '/foo/*path' });
this.route('sample4', { path: '/foo' } ,function() {
this.route('opt', { path: '/(:param)' });
});
});
```

Expand All @@ -110,15 +113,16 @@ The resolution order stays as it is currently. That is
- Greater number of segments means more specific.
- On the same number of segments, static is more specific than dynamic, and dynamic is more specific
than globs.
- In case of tie, the first defined route wins
- In case of tie in the number and type of segments, the route with more handlers wins.
- If all the previous fail, the first defined route wins

Examples:

```
/foo/bar => 'sample1' (two segments, both static)
/foo/dynamic => 'sample2' (two segments, one static, one dynamic)
Copy link
Member

@nathanhammond nathanhammond Jul 22, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be sample4.opt because it has more handlers.

/foo/something/else => 'sample3' (two segments, one static, one glob)
/foo => 'sample2' (one static segment)
/foo => 'sample4' (one static segment, but wins over sample 2 because has more handlers)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be sample2 because that definition creates an accepting state for /foo and is defined before sample4.

```

### Dynamic Segment Constraints
Expand Down