-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
Expose the url-to-options
function from internal/url.js
#34349
Comments
I'm inclined to say it's better to copy it out into a npm module than to expose it because:
|
I strongly disagree. If this was trivial then it wouldn't be used in the
Hmm... After giving it some thought I'd go for
That's the cost you always have to take. It's already used in the |
It's trivial in the sense that it doesn't do anything that ordinary JS code cannot also do. It it needed runtime magic or if you needed to go to extreme lengths to make it do something that's trivial for core code, that's a compelling argument to expose it, but that doesn't apply here. There are exceptions to the rule (
The distinction here is that it's only indirectly observable to user code. For example, we don't have to worry about callers passing something that's not a URL object. |
Then let's completely remove the You get me wrong, I just don't want to duplicate what already exists in the Node.js core.
Because it's almost not observable to user code it doesn't mean that it doesn't have any impact. If Although the end user won't have to use There's already an NPM package called Even On the other side, |
PR-URL: nodejs#35960 Fixes: nodejs#34349 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
Is your feature request related to a problem? Please describe.
#14570 (comment)
Describe the solution you'd like
Expose the
urlToOptions
module so it can be imported e.g.const {urlToOptions} = require('url');
That way we could easily convert a URL instance without duplicating the code like this.
Describe alternatives you've considered
No, duplicates increase the package size.
The text was updated successfully, but these errors were encountered: