Skip to content
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
Merged

Use WHATWG URL for request.url #3822

merged 4 commits into from
Nov 6, 2018

Conversation

kanongil
Copy link
Contributor

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 kanongil added feature New functionality or improvement breaking changes Change that can breaking existing code labels Sep 11, 2018
@kanongil
Copy link
Contributor Author

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
hueniverse added a commit that referenced this pull request Nov 7, 2018
@hueniverse
Copy link
Contributor

I changed it to be more consistent and less flexible.

timneutkens pushed a commit to vercel/next.js that referenced this pull request Feb 24, 2019
Since version 18 (released in January), Hapi's `request.url` returns the parsed URL, so `parse` is not needed.

Ref:
- https://hapijs.com/api#-requesturl
- hapijs/hapi#3822
@lock
Copy link

lock bot commented Jan 9, 2020

This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
breaking changes Change that can breaking existing code feature New functionality or improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants