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

Multiple leading slashes in path causes hostname to be parsed incorrectly #3965

BanovMiroslav opened this issue Aug 13, 2019 · 0 comments


Copy link

@BanovMiroslav BanovMiroslav commented Aug 13, 2019

Steps to reproduce

Urls such as http://localhost:3000//path cause incorrect parsing of the url.

Here is a catch-all route to show the result:

    method: 'GET',
    path: '/{p*}',
    handler: (request, h) => {
      return {
        p_param: request.params.p,
        request_url: request.url,
        request_path: request.path,

What was the result you received?


What did you expect?



  • node version: v10.16.2
  • hapi version: 18.3.1
  • os: Ubuntu 18.04.3 LTS


In _setUrl this code relies on native nodejs Url.URL class.

const base = (url[0] === '/' ? `${}://${ || `${}:${}`}` : undefined);

url = new Url.URL(url, base);

Problem is url "//path" is protocol-relative url that has only domain component. So it is considered absolute for the purpose of the call and base is ignored.

@hueniverse hueniverse self-assigned this Sep 15, 2019
@hueniverse hueniverse added the bug label Sep 15, 2019
@hueniverse hueniverse added this to the 18.4.0 milestone Sep 15, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Mar 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants