emberjs/ember.js — pull request #1103 by blt04 (2012-07-02 17:35:44+00:00)
Title: Support non-nested states with nested paths

This is my second attempt at improving support for non-nested states with nested paths. (see also emberjs/ember.js#1005).

Sometimes you want to add non-nested routes with nested paths. For example:

Ember.Router.create({
root: Ember.Route.create({
products: Ember.Route.create({
route: '/products',
show: Ember.Route.create({
route: '/:product_id',
index: Ember.Route.creaet({
route: '/'
})
})
}),
services: Ember.Route.create({
route: '/products/:product_id/services',
show: Ember.Route.create({
route: '/:service_id',
index: Ember.Route.creaet({
route: '/'
})
})
})
})
});

Currently, ember will not route to these states correctly using the back/forward buttons (`routePath` and `unroutePath`).

This fixes `routePath` by improving the sorting algorithm to sort by each segment in the URL (99e20d599b9).

It fixes `unroutePath` by computing the next state instead of relying on URL prefixes (b1556c6234f).

These fixes could both be improved by pre-caching routes, however this works for the time being.