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: re-add path in url.format #893

Closed
wants to merge 2 commits into from
Closed

url: re-add path in url.format #893

wants to merge 2 commits into from

Conversation

yorkie
Copy link
Contributor

@yorkie yorkie commented Feb 19, 2015

This PR re-added the commit d312b6d that reverted at #303, and in this time, I did cover the test with the case git+ssh://git@github.com:<user>/<repo> and let it passed:

> url.parse('git+ssh://git@github.com:iojs/io.js.git')
{ protocol: 'git+ssh:',
  slashes: true,
  auth: 'git',
  host: 'github.com',
  port: null,
  hostname: 'github.com',
  hash: null,
  search: null,
  query: null,
  pathname: '/:iojs/io.js.git',
  path: '/:iojs/io.js.git',
  href: 'git+ssh://git@github.com/:iojs/io.js.git' }

R= @bnoordhuis @evanlucas /cc @rvagg

@piscisaureus
Copy link
Contributor

node.js has rejected this patch because it could not decide what to do when the object contains both 'path' and 'pathname'. I don't think that iojs has answered that question, although the tests seem to contain some rules.

@rvagg
Copy link
Member

rvagg commented Feb 19, 2015

my vote would be top prioritise path if it exists as it represents a parent to pathname and querystring and could be thought of as a parent - I say we just come up with decision about which is authoritative and be done with it.

@yorkie
Copy link
Contributor Author

yorkie commented Feb 20, 2015

node.js has rejected this patch because it could not decide what to do when the object contains both 'path' and 'pathname'.

@piscisaureus @chrisdickinson has merged the patch at nodejs/node-v0.x-archive#8755, and we have discussed how the path acts as in the format() and parse() at nodejs/node-v0.x-archive#8755 (comment), it should be consistent with @rvagg's above vote.

Actually the most initial purpose of this patch is to keep url module consistent with http module as I described at nodejs/node-v0.x-archive#8722 that I talked with @indutny.

Btw, this issue is not big deal to me, I just wanna let the url in our internal modules be neater, so if you guys think it breaks too much, feel free to close it.

@piscisaureus
Copy link
Contributor

Ok, the discussion in node seems to have been thorough enough so I move io accepts the patch as well.
The only thing that's needed is a semver range. What is this, semver-minor (added feature) ?

@yorkie
Copy link
Contributor Author

yorkie commented Feb 21, 2015

Thank you @piscisaureus, as for semver-minor, I think minor is good, because I wasn't fixing anything else :)

@rvagg
Copy link
Member

rvagg commented Feb 21, 2015

@chrisdickinson
Copy link
Contributor

This will be a major change in practice, unfortunately. Consider code that accepts a string, 'url.parse's it, changes the pathname, and formats it, before handing the string to another function. This change will break that behavior, because "path" will be present on the parsed url object and will take precedence over "pathname".

@chrisdickinson
Copy link
Contributor

An example:

var url = require('url');

module.exports = myCode;

function myCode(sourceURL) {
  var parsed = url.parse(sourceURL);
  parsed.pathname = '/updated/by/proxy';
  return url.format(parsed);
}

One solution might be to (hurk) start introducing setters and getters on properties of the Url instances returned by url.parse, so that updating one key updates parent keys as well.

@yorkie
Copy link
Contributor Author

yorkie commented Feb 21, 2015

Wow~ neat @chrisdickinson the pathname should be watched and effects on path, search and query fields, right?

Perhaps we are able to add the watching after the current build is passed, could someone please help me with failures of testing on https://jenkins-iojs.nodesource.com/job/iojs+any-pr+multi/187/?

Actually I could not find a way to reproduce and moreover unsure if the errors is introduced by this patch because the same errors is also printed at the following builds:

/cc @rvagg

@rvagg
Copy link
Member

rvagg commented Feb 22, 2015

you can ignore all those reds, freebsd and armv6 have persistent problems that are yet to be resolved

@yorkie
Copy link
Contributor Author

yorkie commented Feb 22, 2015

Okay, thanks for your telling, will do watching by following @chrisdickinson's comment.

@yorkie
Copy link
Contributor Author

yorkie commented Feb 25, 2015

Hi @rvagg @chrisdickinson added setter/getter and related tests, could someone please take a look, thanks :)

@rvagg
Copy link
Member

rvagg commented Feb 25, 2015

@chrisdickinson can you semver-* label this? Do you still believe it to be semver-major?

@yorkie
Copy link
Contributor Author

yorkie commented Feb 26, 2015

btw, I didn't introduce setter/getter on other fields like host/hostname/href/etc., so if this is tagged as major, perhaps I can do this with those fields, though :)

@yorkie
Copy link
Contributor Author

yorkie commented Feb 28, 2015

ping @chrisdickinson

@chrisdickinson chrisdickinson added the semver-major PRs that contain breaking changes and should be released in the next major version. label Feb 28, 2015
@chrisdickinson
Copy link
Contributor

I'm not sure what the best course of action is, here. #933 also adds this behavior, and we're kind of at an impasse – a change like this stands to break a lot of code on npm, but it also makes the URL object how I expect it should. We should discuss this along with #933 at the next TC meeting.

@yorkie
Copy link
Contributor Author

yorkie commented Feb 28, 2015

And actually when I run npm install git+ssh://git@github.com:caolan/async.git#master it still didn't work, but it worked at node v0.10.32.

So I ran the following:

# in node
> node
> url.parse('git+ssh://git@github.com:caolan/async.git#master');
{ protocol: 'git+ssh:',
  slashes: true,
  auth: 'git',
  host: 'github.com',
  port: null,
  hostname: 'github.com',
  hash: '#master',
  search: null,
  query: null,
  pathname: '/:caolan/async.git',
  path: '/:caolan/async.git',
  href: 'git+ssh://git@github.com/:caolan/async.git#master' }
# in iojs with mine
> node
> url.parse('git+ssh://git@github.com:caolan/async.git#master').data;
{ protocol: 'git+ssh:',
  slashes: true,
  auth: 'git',
  host: 'github.com',
  port: null,
  hostname: 'github.com',
  hash: '#master',
  href: 'git+ssh://git@github.com/:caolan/async.git#master',
  path: '/:caolan/async.git',
  pathname: '/:caolan/async.git',
  search: null,
  query: null }

So I guess as you have said, there are some changes on npm, let's waiting for that action, Thanks for your quick updates :)

@bnoordhuis
Copy link
Member

What's the verdict on this PR? If it's acceptable for v2.x, can someone LGTM it?

@petkaantonov
Copy link
Contributor

This looks like it would conflict a lot with the performance patch, so not LGTM :)

@yorkie
Copy link
Contributor Author

yorkie commented Mar 21, 2015

I'm still waiting for that patch as well, i will fix conflicts once that would be merged

@mscdex mscdex added the url Issues and PRs related to the legacy built-in url module. label Mar 22, 2015
@Qard
Copy link
Member

Qard commented Jun 26, 2015

@nodejs/tsc Since @petkaantonov has been too busy to do anything with #1650 and it's at a point where it needs rebasing anyway, I suggest we consider this for 3.x.

@yorkie
Copy link
Contributor Author

yorkie commented Jun 27, 2015

If @petkaantonov and one or more of TSC agreed with, I would be so happy to working on #1650 from July so that we are able to work on this as well. This 2 has been suspended too long IMHO :)

@Qard Qard mentioned this pull request Jun 29, 2015
@chrisdickinson
Copy link
Contributor

@Qard Hold up on merging this still, this will break a lot of downstream code.

@jasnell jasnell added the stalled Issues and PRs that are stalled. label Nov 16, 2015
@yorkie yorkie closed this Nov 26, 2015
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. stalled Issues and PRs that are stalled. 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.

9 participants