-
Notifications
You must be signed in to change notification settings - Fork 7.3k
url.format
strips query in 0.11.15
#9070
Comments
@pierre-elie Thank you for reporting this issue! Just because it's a bit easier to copy/paste, here's a repro of this issue as text:
The breaking change is d312b6d. @chrisdickinson Do you have some time to take a look at it? |
|
Closing this issue as "works as expected." |
I find it very confusing that the code mentioned above silently swallows the It seems that the reason for having a |
Reopening to continue the discussion. |
For my part, I'm okay with higher level keys overriding lower level keys (even silently), and -0 on making Some potential paths out of this:
3 and 4 leave us (and users) in the same state – leaning on documentation, and without the ability to pass the output of |
Definitely understand the logic but it's certainly non-obvious. At the very least, this needs to be clearly described in the api docs. |
1 -- doesn't solve the problem of user creating invalid input In the event of throwing users at least have recourse to read the documentation, with silent action things are happening and they may not be aware of it. I think this would be a good conversation to have during the call tomorrow morning. |
There is perhaps a 5th option... it breaks api compatibility but perhaps that is ok: Have the result of parse() return an object that has it's own format() method, the input of which allows a developer to pass in overriding values that are taken before the parse object's own.. e.g. var parsed = url.parse('http://www.example.org/path?a=b');
var formatted = parsed.format({path:'/alternative/path?c=d'}); Here the override would have to be explicit and the original parsed object remains untouched by the overrides. We can throw as suggested if the input to format contains conflicting values (e.g. |
Recording the results of the meeting: In the future we will throw on all conflicting keys – that is, if |
@chrisdickinson @tjfontaine Sorry to continue on a discussion after we agreed on a decision, but I'd like to express one concern that I didn't mention during the meeting. It seems to me that throwing in |
Sorry I couldn't make the call earlier and pitch in on the discussion around this but I share a bit of the same concern as @misterdjules. When the throw actually happens, it may be somewhat difficult to back track to pinpoint the actual problem but I'm not entirely certain we'll be able to do much about that. My key concern is with the part, "if |
Throw an error if path and any of pathname, query, or search conflict. Fixes: nodejs#9070
This reverts commit d312b6d. d312b6d introduced some confusion in the existing API of url.format and url.parse. The way the 'path' property overrides other properties in url.format's input is too confusing for existing users compared to the issues it fixes. Fixes such as nodejs#9081 have been proposed, but they do not make the API less confusing. Instead, this change just reverts the original breaking change so that it gives us more time after v0.12.0 is released to come up with a better API for url.format, url.parse and other related APIs in the v0.13 development branch. Fixes nodejs#9070. Conflicts: doc/api/url.markdown
This reverts commit d312b6d. d312b6d introduced some confusion in the existing API of url.format and url.parse. The way the 'path' property overrides other properties in url.format's input is too confusing for existing users compared to the issues it fixes. Fixes such as nodejs#9081 have been proposed, but they do not make the API less confusing. Instead, this change just reverts the original breaking change so that it gives us more time after v0.12.0 is released to come up with a better API for url.format, url.parse and other related APIs in the v0.13 development branch. Fixes nodejs#9070. Conflicts: doc/api/url.markdown PR: nodejs#9109 PR-URL: nodejs#9109 Reviewed-By: Timothy J Fontaine <tjfontaine@gmail.com>
This reverts commit d312b6d. d312b6d introduced some confusion in the existing API of url.format and url.parse. The way the 'path' property overrides other properties in url.format's input is too confusing for existing users compared to the issues it fixes. Fixes such as nodejs#9081 have been proposed, but they do not make the API less confusing. Instead, this change just reverts the original breaking change so that it gives us more time after v0.12.0 is released to come up with a better API for url.format, url.parse and other related APIs in the v0.13 development branch. Fixes nodejs#9070. Conflicts: doc/api/url.markdown PR: nodejs#9109 PR-URL: nodejs#9109 Reviewed-By: Timothy J Fontaine <tjfontaine@gmail.com>
Fixed by 3b392d3. Thank you @pierre-elie and all for your help! |
In
0.11.15
,url.format(urlObj)
seems to removequery
fromurlObj
and does not include it in the formatted url.0.11.14
does not have this issue.The text was updated successfully, but these errors were encountered: