function get_port(loc) {
  if (loc.port) {
    return loc.port;
  }
  return loc.protocol === 'https:' ? '443' : '80';
}
When a default port is used, location.port returns the empty string.
This function attempts to provide an exact port, assuming we are running under wptserve.
@param {*} loc - can be Location/<a>/<area>/URL, but assumes http/https only.
@returns {string} The port number.