Correct me if I'm wrong, but couldn't your code just have easily used hostname as opposed to host since that's what you were specifically interested in?
That's not exactly what I'm referring to. You could assume behavior would be similar to or equivalent to how window.location.host and window.location.hostname behave. This is especially true when we don't care about ports, as is the case with window.location.hostname.