gonzalocasas / node-proxy-middleware

proxy as middleware
MIT License
146 stars 65 forks source link

routes with a trailing '/' #21

Closed duhseekoh closed 9 years ago

duhseekoh commented 9 years ago

When a route is specified on the options, an extra / is added on the end. So the route specified is not actually matched with the request url if the request url doesn't contain a trailing / also.

var route = slashJoin(options.route, ''); The line turns a specified route like /api/endpointone into /api/endpointone/

So when the boolean check immediately below is ran on the requested url that we want to proxy its comparing: "/api/endpointone" === "/api/endpointone/" which is obviously not true.

A realistic and valid use case is to be able to pass in a route with no trailing slash and expect that to match with requested urls with no trailing slash.

andrewrk commented 9 years ago

Thanks for the error report. Interested in implementing a fix and writing a test? The module is pretty small.

noahgrant commented 9 years ago

+1!

amr commented 9 years ago

Any chance this will be merged soon?

andrewrk commented 9 years ago

Not without a test case.

andrewrk commented 9 years ago

@amr looks like you're referring to @noahgrant's commit, which indeed has a test, and, in fact, has already been merged. I believe this issue is closed now.