Closed bliitzkrieg closed 6 years ago
Thanks for pointing that out! Sounds like a bug indeed. I couldn't yet take the time to look into it, PR welcome!
Hey - I looked into the issue further and it looks like when the href is created it puts undefined when an optional param doesn't exist so /page?lang=undefined&slug=some-slug
.
Looks like the issue is here:
https://github.com/fridays/next-routes/blob/master/src/index.js#L145 specifically the toQuerystring
function. Solution may be to use a .filter
before the .map
to filter out undefined.
Fixed in version 1.1.0!
I have the following optional route
routes.add('page', '/:lang?/page/:slug')
and when I go to/page/some-slug
, the query that I get fromgetInitialProps
is{ lang: "undefined", slug: "some-slug" }
. The lang is returning a string type instead of undefined typed which I think is a bug. In path-to-regexp, the optional param returns an actual undefined typed (tested myself).If I go to
/en/page/some-slug
, I get both params correctly.Is this a known bug?