p-meier / hapi-api-version

An API versioning plugin for hapi.
Apache License 2.0
74 stars 26 forks source link

Don't assume what server.match returns #2

Closed ejeklint closed 8 years ago

ejeklint commented 8 years ago

server.match() (or connection.match()) returns a matching route which doesn't have to be what you searched for. When serving static files for example, it's common to have a route like /{files*} which is a catch-all when other matches fail.

If you have defined /foo and /{files*} and try to match /v1/foo then .match will actually return /{files*} which is the last possible match. So you shouldn't assume a non-null result is the route you searched for.

p-meier commented 8 years ago

Thanks you for your PR. Did not think of that case.