-
Notifications
You must be signed in to change notification settings - Fork 43
HTTPS.Request() does not accept WHATWG URL #26
Comments
@JonathanWilbur thanks a lot for the accurate and detailed diagnosis! Would you be willing to submit a PR that fixes this? (It's okay if you cannot, just asking before I try to take a stab at this myself :)) |
@JonathanWilbur Thank you for filing this! I'm trying to use Google's cloud-storage API. My code had been working fine, making its https requests. But once I added It boils down to the fact that @google-cloud/storage ultimately depends upon The workaround (until this bug is fixed) was simple: I just switch from
|
@BYK I do not plan on fixing this bug. I am just too busy with other projects I consider to be of higher priority. Just letting you know so you can respond. |
I'll try to look into this over the weekend then. Thanks again @JonathanWilbur! |
Just to note, I believe there's an addition separate bug beyond the "Object.assign failing to copy all fields" issue that @JonathanWilbur mentioned. Look at this code from patch-core.js:
Consider a call to |
And there's a third separate bug. Look at this code from patch-code.js:
Consider a call to Consider a call to Once again, the impact is that my app used to be able to use |
@ljw1004 - do you think you can provide me some test cases to work off of for a fix? |
Hi! I'm new here. What's the solution? Instead of Object.assign, what should we use? With some help I can get this out asap ❤️ |
This is an attempt to support WHATWG URLs. Feedback is appreciated! Fixes #26
@BYK, @ljw1004, @JonathanWilbur Hi! I did this PR to attempt to fix this issue: #28 Feedback is appreciated! ✨ |
Thanks a lot @sadasant! I added a few comments to the PR and I hope we can merge the PR soon and help all others! :) |
I haven't had time to continue with this! I'll do my best to have an update in the near future. |
Please try out |
NodeJS has a new URL object: the WHATWG URL. This library was clearly designed for what is now known as the "Legacy URL" API. See: https://nodejs.org/docs/latest-v8.x/api/url.html.
When
https.get
inpatch-core.js
is called with a new WHATWGURL
object, the call toObject.assign()
does not copy over things likehostname
andprotocol
andport
, because, unlike with the Legacy URL API, these are getters.The result of the call to
Object.assign()
using the Legacy URL API looks like this:The result of the call to
Object.assign()
when using the newer WHATWG URL API looks like this:This means that, when
https.get()
is called with the newer WHATWG URL, an object that does not contain all of the mandatory parameters is passed into the standard library'shttps.get()
. As it turns out, this incomplete object manages to slip through, because it has the one mandatory property that theHTTPS
module checks for to determine if it is a WHATWG URL:Then, when
urlToOptions()
in theHTTPS
module is called, it crashes, becausehostname
is undefined:The Solution
Make
https.request
inpatch-core.js
check for the properties of the WHATWG URL and use a different methodology to clone it if it is.The text was updated successfully, but these errors were encountered: