baseprime / grapnel

The smallest JavaScript router with named parameters, HTML5 pushState, and middleware support
http://grapnel.js.org
467 stars 40 forks source link

No routes matched #8

Closed tommyy closed 10 years ago

tommyy commented 10 years ago

Is it possible to check if no routes are matched? If no routes are matched, i'm thinking of redirecting the user to a 404 page.

baseprime commented 10 years ago

@tommyy:

router.on('hashchange', function(){
    if(this.action && !this.matches().length){
        // 404
    }
});

Download the new source because a bug was recently fixed. :]