p-meier / hapi-api-version

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

Attempt url decoding before calling server.match #31

Closed cluxton closed 5 years ago

cluxton commented 5 years ago

The Hapi server.match method converts badRequest responses into Hoek assertion errors [1]. This causes malformed URLs to result in 500 errors in applications that use this plugin.

This fix attempts to decode the URI earlier and throws the appropriate badRequest error if it encounters any decoding errors.

[1] https://github.com/hapijs/hapi/blob/master/lib/server.js#L350