Pregunta

I have a route that catches all missing routes and renders a 404-style page. I would like to create a route that matches any url starts with "/browse/" such as "/browse/shoes/red". This seems like the correct way to do that:

App.Router.map(function() {
  this.route('browse', { path: '/browse/*fields' });
  this.route('missing', { path: '/*badPath' });
});

However, ember's RouteRecognizer always picks the missing route over the browse route. (The logic that does this is in sortSolutions of route-recognizer.js .) Is this a bug in Ember? Is there a right way to use glob routes and still have a 404 handler?

By the way, I can create a resource for browse instead of making it a route like this:

App.Router.map(function() {
  this.resource('browse', { path: '/browse' }, function() {
    this.route('baz', {path: '/*'});
  });
  this.route('missing', { path: '*' });
});

This still has the same problem.

¿Fue útil?

Solución

I think this must be a bug...

Here's a JSBin : http://jsbin.com/ucanam/1403/edit

Here you can see it going directly to the 'missing' route as expected:

http://jsbin.com/ucanam/1403#/some/random/stuff

And a failed attempt at going directly to a 'browse' route :

http://jsbin.com/ucanam/1403#/browse/test/stuff

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top