baseprime / grapnel

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

Route handler fires twice on initial load in Safari when using pushState #24

Closed asabhaney closed 9 years ago

asabhaney commented 9 years ago

There seems to be an issue in only Safari that causes the matching route handler to fire twice when the page is first loaded when using pushState. It seems related to the window's popstate event being fired on page load.

Here is an example of the code causing the issue:

var router = new Grapnel({ pushState : true });

router.get('/test/:id?', function(req) {
   console.log('Route handler fired', req.params.id);
});

Tested using Safari 8.0.2.

Awesome plugin, keep up the great work!

baseprime commented 9 years ago

@asabhaney Landed in v0.5.4

Thanks! :]