Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Drop req.url.path which hapi no longer needs. Improves #89. #1

Closed
wants to merge 4 commits into from

Conversation

rektide
Copy link
Owner

@rektide rektide commented Feb 23, 2022

Hapi used to rely on using req.url.path but as of pinojs#29 it was found to throw in some cases & hapi support now uses req.path instead. We can remove the old req.url.path if we feel comfortable doing so.

It's possible someone else somewhere may depend on this. But it would be nice to make this somewhat busy part of the code-base cleaner, if we dare.

in pinojs#29 we preferred req.path, because req.url would throw in hapi if the path was invalid. in restify though, req.path is a function, and this change made the url no longer log. check req.path to see if it is a function, and invoke it if it is.
restify has a req.path but it's a function that returns an object. rather than try to determine how to handle path if we have it, only use path if it's a simple string. otherwise, keep using req.url, like we used to pre pinojs#29.
it's tempting to simply stop looking at req.url.path altogether, since that was introduced for hapi 17 in pinojs@83d58a7#diff-2c4782cb20f7f0d7ca90c7bc04939f4420c4bdb42fdce618984da393ba9202f7R60 .

but since pinojs#29 we look at req.path first, which is safer in hapi, so hapi doesn't care about req.url.path anymore.

but perhaps someone else does depend on req.url.path . so for now, continuing to look at req.url.path , which means a bit more guarding in the req serializer.
@rektide
Copy link
Owner Author

rektide commented Feb 23, 2022

wrong target

@rektide rektide closed this Feb 23, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant