route-parser
route-parser copied to clipboard
Route match includes extra params
I am using qs to append arbitrary URL params to a route.
However when I match this back, it returns the additional params I added.
I would expect the below example to return { alertId: "456", id: "123" }
var route = new Route('/feeditems/:id?useralertId=:alertId')
var myEndpoint = route.reverse({ id: 123, alertId: 456 })
// Appending extra params with qs
myEndpoint += '&' + qs.stringify({ extraParam: 'value' }) // /feeditems/123?useralertId=456&extraParam=value
route.match('/feeditems/123?useralertId=456&extraParam=value')
/*
Returns
{
alertId: "456&extraParam=value",
id: "123"
}
*/
I guess it's intended to be used with location.pathname, which doesn't contain the query / search.
Note that what you mean is not route parameters, but query parameters.