Skip to content

url: .search property is inconsistent depending on parseQueryString #13404

@tniessen

Description

@tniessen
  • Version: master
  • Platform: Windows
  • Subsystem: url

Parsing a URL without a search part changes its behavior if parseQueryString is set:

> url.parse('http://example.com/', false).search
null
> url.parse('http://example.com/', true).search
''

We should probably change this line

this.search = '';

to this

this.search = null;

Users most likely will not expect parseQueryString to affect the value of .search.


There was a similar discussion at #9600, but @sam-github and I both think that the behavior discussed there is in fact justifiable.

Is there any justification for this behavior or do we consider this a bug? If we do, I will create a semver-major PR later. (I know that we do not plan to make any big changes to the old url API, but I would personally consider this a bug.)


cc @nodejs/url

Metadata

Metadata

Assignees

No one assigned

    Labels

    urlIssues and PRs related to the legacy built-in url module.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions