route-parser icon indicating copy to clipboard operation
route-parser copied to clipboard

Route match includes extra params

Open whawker opened this issue 7 years ago • 1 comments

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"
}
*/

whawker avatar May 02 '18 14:05 whawker

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.

m-lautenbach avatar May 23 '18 12:05 m-lautenbach