-
Notifications
You must be signed in to change notification settings - Fork 107
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
Option to keep default port #132
Comments
Yes, no, maybe. The current behavior is modeling the way node and browser parse URL's. We currently already support 3 different URL arguments, adding a 4th argument would really over bloat it given how small this specific use case would be. If were to decide to change to I guess we could change the API to Thoughts? |
I'm not very happy with adding an additional parameter either as I think this is an edge case. In some cases we can't be consistent with both legacy and WHATWG URL parsers because they have different behaviours. |
I definitely agree that adding 4th parameter is not pretty. |
Out of curiosity, why is hiding of the default port needed? Is it to be compatible with other browser/node URL parsers? Imho it is a bit of a surprising behavior, especially for parsing. |
Yes, see https://url.spec.whatwg.org/#port-state. |
Came across this issue trying to find out why url-parse wouldn't parse my port number. Odd behavior if you ask me. Didn't see this in the docs either. |
I'm more than happy to merge any documentation updates ;-) |
Hi, Came across this issue, due to cURL using An alternative solution would be to provide a new getter always returning the port, even if it's the one by default. |
Hi, I assume you refer to this sentence:
It would actually help, if new Url('https://github.com/foo/bar') => { port: '', ... }
new Url('https://github.com:80/foo/bar') => { port: null, ... } |
Currently parsed URL does not contain port when its value is the default for the specified protocol:
It would be great to have an option/parameter to keep the port number even if it is the default for the protocol.
This would be useful when default port is defined by the environment/application requirements and is different from the standard. For example, an application might want to interpret
http://localhost
ashttp://localhost:8080
and nothttp://localhost:80
. Onlyhttp://localhost:80
will be interpreted ashttp://localhost:80
. Right now after URL has been parsed there is no way to know if port was not specified or default port was specified.I'd be glad to provide a PR for this. Not sure if it fine to just add a 4th parameter to the
URL
function.P.S. thanks for this library, it is really convenient and simple to use!
The text was updated successfully, but these errors were encountered: