Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This is exactly the explanation I needed, thank you.

I wonder what the rationale behind this decision was. It seems like a pretty easy way to mess up people like me :D. Any ideas?



Probably some combination of "this is what most browsers do" and wanting to have "http://foo.com:80" and "http://foo.com" have the same underlying representation.


I don't think he's arguing that "http://example.com:80" and "http://example.com" should have different representations: I (and I think he) agrees they should, but that the representation should be "example.com:80", in both cases. I'm not so sure about host, but having port sometimes be "" seems like it could catch people off guard. For host, you now need to watch out for the cases where the port is/isn't present. For port, when it's "".

To me, it's like the type of the variable. The variable "port" should contain the port, not (port|"").


Ah, fair. The fact that port ends up as "" if it's default is almost certainly a "this is what most browsers do" kind of thing.


I think they just wanted to consistently handle the port, rather than exclude it when it is the default. I can understand wanting to be consistent, but their implementation even goes against the W3 specs: http://www.w3.org/TR/url/#url-decomposition-idl-attributes




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: