Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Mixmatch optional params and strings in router middleware #258

Closed
cjoudrey opened this Issue Apr 16, 2011 · 1 comment

Comments

Projects
None yet
3 participants

I just ran into this strange behavior with the router middleware.

I am trying to set the following route: /:year/(page/:page)? which would serve the following URLs:

  • /2011
  • /2011/page/2

The normalizePath function appears to be stripping my /:year completely in the resulting RegExp.

console.log(normalizePath('/:year/(page/:page)?', keys));
console.log(keys);

Output:

/^(?:\/(?:\/page\/:page))?\/?$/i
[ 'year' ]

My goal was to prevent creating two routes.

Are these types of routes simply not supported by Connect?

Member

tj commented Apr 17, 2011

hmm I've definitely done /:year/:page? etc, but I will see if I can tweak things a bit to get this working as you would expect

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment