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

url: ensure search property is consistently null vs empty #13606

Closed
wants to merge 1 commit into from

Conversation

JustinBeckwith
Copy link
Contributor

@JustinBeckwith JustinBeckwith commented Jun 11, 2017

Fixes: #13404

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines
Affected core subsystem(s)

url

@nodejs-github-bot nodejs-github-bot added the url Issues and PRs related to the legacy built-in url module. label Jun 11, 2017
@TimothyGu
Copy link
Member

@Trott
Copy link
Member

Trott commented Jun 11, 2017

We'll probably want to do a CITGM run to get an idea if this breaks stuff in the ecosystem. If so, we should mark it semver-major (and, of course, carefully consider if the breakage is worth it).

Seems good to me, but I'll defer to people more familiar with the url module (like @TimothyGu who's already reviewed it).

@mscdex mscdex added the semver-major PRs that contain breaking changes and should be released in the next major version. label Jun 11, 2017
Copy link
Member

@tniessen tniessen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess my opinion is obvious after creating #13404 :)

@tniessen
Copy link
Member

CI failure on arm is unrelated, see #13603.

@refack
Copy link
Contributor

refack commented Jun 11, 2017

short summary of previous discussion:

  1. disparity:
> url.parse('http://example.com/', false).search
null
> url.parse('http://example.com/', true).search
''
  1. other N/A properties are set to null, not ''

@refack
Copy link
Contributor

refack commented Jun 11, 2017

Copy link
Member

@Trott Trott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Trott
Copy link
Member

Trott commented Jun 11, 2017

Pinging @nodejs/ctc since it's labeled semver-major. (A case could certainly be made that it's semver-patch, but I'm definitely OK with being cautious on this one.)

@indutny
Copy link
Member

indutny commented Jun 11, 2017

@Trott how many releases had "bad" behavior?

@indutny
Copy link
Member

indutny commented Jun 11, 2017

Looks like up to v4, at least. I'd go with semver major then.

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM as semver-major

Copy link
Member

@jasnell jasnell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM as semver-major

@tniessen
Copy link
Member

New CI after #13603 was fixed: https://ci.nodejs.org/job/node-test-pull-request/8625/

@refack
Copy link
Contributor

refack commented Jun 13, 2017

arm-fanned had an infra hiccup, rerunning: https://ci.nodejs.org/job/node-test-commit-arm-fanned/9386/

@jasnell
Copy link
Member

jasnell commented Jun 13, 2017

@refack
Copy link
Contributor

refack commented Jun 13, 2017

CITGM: https://ci.nodejs.org/view/Node.js-citgm/job/citgm-smoker/876/

Had to kill macOS because of known bug nodejs/citgm#426
Other then that CITGM clean ✔️

jasnell pushed a commit that referenced this pull request Jun 13, 2017
PR-URL: #13606
Fixes: #13404
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
@jasnell
Copy link
Member

jasnell commented Jun 13, 2017

Landed in c88ba03

@styfle
Copy link
Member

styfle commented Feb 9, 2018

@JustinBeckwith @jasnell This probably broke userland code like espadrine/sc#65 however I don't see a mention of History in the docs for url.parse. Should this be added?

@TimothyGu
Copy link
Member

@styfle PR/issue welcome.

@styfle styfle mentioned this pull request Feb 9, 2018
3 tasks
@jasnell
Copy link
Member

jasnell commented Feb 9, 2018

Yep, a mention in the doc changelogs would be excellent

@styfle
Copy link
Member

styfle commented Feb 9, 2018

@TimothyGu @jasnell I made a PR.

But after thinking through this, I believe it's better to change null to the empty string.
My reason is that the browser seems to never return null and returns the empty string.
For example, this page window.location.search === '' because there is no query string.
And I like the idea of never using null unless you have to.
In typescript, the type is string | null but if it was never null, you could change the type to string and you would never have to check before doing search.split(',') or search.slice(0).

@JustinBeckwith Why did you decide to use null instead of making both scenarios return empty string?

@JustinBeckwith
Copy link
Contributor Author

I generally don't like returning empty string when we're trying to convey that the value is 'unset'. Those to me mean very different things. That having been said - I was handed this as part of the code & learn at node.js interactive :) I don't think either solution is necessarily wrong, but there would be a cost to flip-flopping.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver-major PRs that contain breaking changes and should be released in the next major version. url Issues and PRs related to the legacy built-in url module.
Projects
None yet
Development

Successfully merging this pull request may close these issues.