hapi icon indicating copy to clipboard operation
hapi copied to clipboard

Make pre-routed request.route property null

Open kanongil opened this issue 2 years ago • 2 comments

This fixes the value of request.route during onRequest processing to closer match the docs. As it is, it just returns the notFound route. I updated the docs to clarify that the value will be null.

The PR ended up being quite extensive, since the internal logic uses the route property when it has not been routed. I fixed this by using the internal _route instead.

This PR also contains a fix for a minor issue with response.escape(true), which would be ignored.

kanongil avatar Mar 12 '23 15:03 kanongil

Note that this is a bug fix to clarify the public API and make the code match this. It might however cause problems for code that uses onRequest extensions that inadvertently relies on the request.route value being set.

kanongil avatar Mar 12 '23 15:03 kanongil

For that reason I wonder if we should save this for the next major. I figure, if folks do currently have this use-case then it will cause a breakage for them, if if they don't have this use-case then they are not experiencing an issue. I suppose the upside here would be that this helps folks who think they have working code but actually do not, due to the ambiguous documentation.

Hmm! What do others think?

devinivy avatar Mar 27 '23 19:03 devinivy