baseprime / grapnel

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

Named parameter with preceding wildcard messes up params. #56

Closed thunderkid closed 8 years ago

thunderkid commented 8 years ago

I'm matching with router.get('*/max/:maxNum', function(req) { console.log(max is ${req.params.maxNum}); });

When I set the url to: ...#/why/max/88

I get req.params = { 1: "88", maxNum: "why" }

That seems wrong. I should be getting just { maxNum: "88" }

baseprime commented 8 years ago

You are not specifying that the route begins with /, #/why/max/88 fails but #why/max/88 does not.

thunderkid commented 8 years ago

Perhaps I'm misunderstanding you. With the above router, setting the browser url to http://localhost:8161/#/why/max/44 gives req.params.maxNum="/why"

And setting the url to http://localhost:8161/#why/max/44 gives req.params.maxNum="why" which is still not what I'd expect.