pregmatch pregmatch - 10 months ago 43
Node.js Question

Are this two routes same in nodejs?

Routes in Express:


I can see that first one is fired for both requests so they are same, but is there a way to solve this without involving for example:



Yes, they are the same.

The router just see a route that starts with search/ and ends with a wildcard. The only thing that change is the name you give to that wildcard, which doesn't matter for the router, it's still the same URL.

You can solve this by either changing the route, or you can parse the route argument (the wildcard) and do something different depending on its value.