function fixHostname()

in src/components/common/EmulatorConfigProvider.tsx [239:256]


function fixHostname(host: string): string {
  // We should never return 0.0.0.0 or :: since they won't work in some OSes:
  // https://github.com/firebase/firebase-tools-ui/issues/286
  if (host === '0.0.0.0') {
    host = window.location.hostname;
    // Replace localhost with IPv4 loopback since some browsers / OSes may
    // resolve it to IPv6 and connection may fail. Ditto for IPv6 cases below.
    if (!host || host === 'localhost') {
      host = '127.0.0.1';
    }
  } else if (host === '::') {
    host = window.location.hostname;
    if (!host || host === 'localhost') {
      host = '::1';
    }
  }
  return host;
}