Skip to content

Return value of url.parse() in nodejs version 16 and 17 is different from old version. #42231

@LvChengbin

Description

@LvChengbin

Version

16.14.0

Platform

No response

Subsystem

No response

What steps will reproduce the bug?

Run the following code with nodejs v15 and v16 gets different output.

const { parse } = require( 'url' );
parse( '//foo@bar' );

Output with nodejs 14:

{
    protocol: null,
    slashes: null,
    auth: null,
    host: null,
    port: null,
    hostname: null,
    hash: null,
    search: null,
    query: null,
    pathname: "//foo@bar",
    path: "//foo@bar",
    href: "//foo@bar"
}

Output with nodejs 16:

{
    protocol: null,
    slashes: true,
    auth: "foo",
    host: "bar",
    port: null,
    hostname: "bar",
    hash: null,
    search: null,
    query: null,
    pathname: null,
    path: null,
    href: "//foo@bar"
}

https://runkit.com/62249077dc641400085658be/6224907756c9c7000882de7a

How often does it reproduce? Is there a required condition?

No response

What is the expected behavior?

No response

What do you see instead?

I am not sure if it's a bug or not, but it's changed and cannot be found from documentation.
https://nodejs.org/dist/latest-v16.x/docs/api/url.html#urlparseurlstring-parsequerystring-slashesdenotehost

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions