New issue

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

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

Already on GitHub? Sign in to your account

Use WHATWG URL for request.url #3822

Merged
merged 4 commits into from Nov 6, 2018

Conversation

Projects
None yet
2 participants
@kanongil
Member

kanongil commented Sep 11, 2018

I had a look into what it would take to update hapi to use the WHATWG URL API since Url.parse() is being deprecated, and node 8 already supports the replacement API.

As far as I can tell, the only directly affected api is the request.url property, and the setUrl() method.

PR details:

  • All usage of old style URL objects, and Url.parse() has been replaced with the new URL API. There is no legacy support.
  • Added a route.queryParser option to retain ability to customize the query parsing. The return value is validated so that request.query will always be an object.
  • request.url property is no longer relative, since the URL constructor won't create relative URLs.
  • setUrl throws a badRequest error if the URL parsing fails.
@kanongil

This comment has been minimized.

Member

kanongil commented Sep 11, 2018

Note: We could probably remove the request.info.hostname and request.info.host fields, since they are now always available on request.url.

@hueniverse hueniverse self-assigned this Nov 6, 2018

@hueniverse hueniverse added this to the 18.0.0 milestone Nov 6, 2018

@hueniverse hueniverse merged commit fa8a55e into hapijs:master Nov 6, 2018

1 of 3 checks passed

continuous-integration/appveyor/pr Waiting for AppVeyor build to complete
Details
continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
Node Security No known vulnerabilities found
Details

hueniverse added a commit that referenced this pull request Nov 7, 2018

@hueniverse

This comment has been minimized.

Member

hueniverse commented Nov 7, 2018

I changed it to be more consistent and less flexible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment