Skip to content

Documentation for http.message.url suggests using deprecated url API #30048

Description

@denilsonsa

At the following piece of documentation (for v12; the latest one):

It describes:

To parse the url into its parts require('url').parse(request.url) can be used:
[…]
…or true can be passed as the second argument to require('url').parse:
[…]

However, this legacy url module/API is deprecated since v11.

Thus, the documentation should be updated.

Bonus points for grepping the rest of the documentation to find other outdated examples.

Activity

  1. lpinca commented on Oct 21, 2019

    @lpinca
    Member

    The WHATWG URL API will not work in this case unless a bogus base URL is provided as second argument.

  2. added
    docIssues and PRs related to Node.js documentation.
    on Oct 21, 2019
  3. saitolume commented on Nov 12, 2019

    @saitolume
    Contributor

    @lpinca Can I work on this issue?
    This is my first time contributing to Node.js

  4. lpinca commented on Nov 12, 2019

    @lpinca
    Member

    Yes but again, there is no equivalent for WHATWG URL.

  5. saitolume commented on Nov 12, 2019

    @saitolume
    Contributor

    Hmm… Should I remove deprecated docs or update with WHATWG URL to provide a bogus URL as second argument?

    If the later, I will replace it like this:

    > new URL('/status?name=ryan', 'https://nodejs.org')
    URL {
      href: 'https://nodejs.org/status?name=ryan',
      origin: 'https://nodejs.org',
      protocol: 'https:',
      username: '',
      password: '',
      host: 'nodejs.org',
      hostname: 'nodejs.org',
      port: '',
      pathname: '/status',
      search: '?name=ryan',
      searchParams: URLSearchParams { 'name' => 'ryan' },
      hash: ''
    }
  6. lpinca commented on Nov 15, 2019

    @lpinca
    Member

    @nodejs/url

  7. dev-script commented on Nov 25, 2019

    @dev-script
    Contributor

    @lpinca i would like to work on this issue.

  8. joyeecheung commented on Dec 5, 2019

    @joyeecheung
    Member

    In the context of http.IncomingMessage, it might make sense to suggest something like

    new URL(request.url, `http://${request.headers.host}`);
    

    (or http:// can be replaced with a ${protocol}:// to be more generic. Of course this does not work if request.headers does not actually contain host but I guess in that case a 404 should already be sent anyway)

    Then give some examples like the one in #30048 (comment)

  9. saitolume commented on Dec 6, 2019

    @saitolume
    Contributor

    @joyeecheung Thank you for a good idea! I will try to refactor doc soon.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    docIssues and PRs related to Node.js documentation.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions