You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be nice to allow WHATWG URL objects (implemented in node's URL API since v6.13.0, globally available since v10.0.0).
Since we are here, it would be nice to get rid of the legacy url.parse and simply use new URL(...) instead.
This may be a breaking change due to the fact that the legecay parser is slightly different than the WHATWG parser. I do not know what the differences are, but I imagine they are subtle and that some users have come to rely on the legacy implementation.
Alternatives
I can stringify URLs - but these strings are parsed... which is unnecessary.
// this works, but the stringification is not necessaryconstapiServer=newURL('http://localhost:8888');nock(`${apiServer}`)...
If the feature request is accepted, would you be willing to submit a PR?
yes
The text was updated successfully, but these errors were encountered:
I took a stab at implementing this and wanted to post my initial findings. After digging through tests, I eventually found an attempt was made several years ago and it never got completed: #1692. The conversation in that PR highlights the biggest issue I've run into, but I'll recap here:
There is an unfortunate difference between the legacy url.parse and the WHATWG parser (new Url) regarding the hostname for bracketed IPv6 addresses:
Note the preservation of brackets in the WHATWG URL. This presents a few challenges:
preserving backwards compatability
treating [2607:f0d0:1002:51::5] and 2607:f0d0:1002:51::5 as equals... they're indeed the same hostname
Long story short, all of the above challenges are "solved" by keeping internal references to the non-bracketed hostnames - effectively preserving the legacy parsing behavior while still using the WHATWG parser and all of it's robustness. Here is some pseudo code:
All internal matching and filtering should take place on the normalizedHostname. This should be fairly easy to implement, and I will port over some of the other changes made the previous PR.
Please avoid duplicates
Context
It would be nice to allow WHATWG URL objects (implemented in node's URL API since v6.13.0, globally available since v10.0.0).
Since we are here, it would be nice to get rid of the legacy
url.parse
and simply usenew URL(...)
instead.This may be a breaking change due to the fact that the legecay parser is slightly different than the WHATWG parser. I do not know what the differences are, but I imagine they are subtle and that some users have come to rely on the legacy implementation.
Alternatives
I can stringify URLs - but these strings are parsed... which is unnecessary.
If the feature request is accepted, would you be willing to submit a PR?
The text was updated successfully, but these errors were encountered: