Skip to content

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

Closed
JustinBeckwith wants to merge 1 commit into
nodejs:masterfrom
JustinBeckwith:13404
Closed

url: ensure search property is consistently null vs empty#13606
JustinBeckwith wants to merge 1 commit into
nodejs:masterfrom
JustinBeckwith:13404

Conversation

@JustinBeckwith

@JustinBeckwithJustinBeckwith commented Jun 11, 2017

Copy link
Copy Markdown
Contributor

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-botnodejs-github-bot added the url Issues and PRs related to the legacy built-in url module. label Jun 11, 2017
@TimothyGu

Copy link
Copy Markdown
Member

@Trott

Copy link
Copy Markdown
Member

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).

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

@tniessentniessen left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown
Member

CI failure on arm is unrelated, see #13603.

@refack

Copy link
Copy Markdown
Contributor

short summary of previous discussion:

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

@refack

Copy link
Copy Markdown
Contributor

@TrottTrott left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@Trott

Trott commented Jun 11, 2017

Copy link
Copy Markdown
Member

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
Copy Markdown
Member

@Trott how many releases had "bad" behavior?

@indutny

Copy link
Copy Markdown
Member

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

@mcollinamcollina left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM as semver-major

@jasnelljasnell left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown
Member

@refack

refack commented Jun 13, 2017

Copy link
Copy Markdown
Contributor

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

@jasnell

Copy link
Copy Markdown
Member

@refack

Copy link
Copy Markdown
Contributor

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: #13606Fixes: #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
Copy Markdown
Member

Landed in c88ba03

@styfle

Copy link
Copy Markdown
Member

@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
Copy Markdown
Member

@styfle PR/issue welcome.

@styflestyfle mentioned this pull request Feb 9, 2018
3 tasks
@jasnell

Copy link
Copy Markdown
Member

Yep, a mention in the doc changelogs would be excellent

@styfle

Copy link
Copy Markdown
Member

@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
Copy Markdown
ContributorAuthor

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 freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

semver-majorPRs that contain breaking changes and should be released in the next major version.urlIssues and PRs related to the legacy built-in url module.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

16 participants

@JustinBeckwith@TimothyGu@Trott@tniessen@refack@indutny@jasnell@styfle@mcollina@lpinca@watilde@cjihrig@hiroppy@joyeecheung@mscdex@nodejs-github-bot