baseprime / grapnel

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

Home Route #7

Closed waxim closed 10 years ago

waxim commented 11 years ago

There is currently no way to register a "home" route, to be triggered when the hash is empty?

router.get("#", function(){ console.log('fired every time we have no hash value'); });
waxim commented 11 years ago

Modified line 156

return (window.location.hash) ? window.location.hash.split('#')[1] : "default";

now I can register a controller as "default"

baseprime commented 10 years ago

The home route us triggered by providing an empty route:

var router = new Grapnel();

router.get('', function(req){
    // Do stuff
});