function isGoodLink (link) {
  if (
    typeof link !== 'string' ||
    link.split('#')[0] === location.href.split('#')[0]
  ) {
    return false
  }
  try {
    let u = new URL(decodeURI(link).trim().toLocaleLowerCase())
    //check if host is a private/internal ip
    if (
      u.hostname === 'localhost' ||
      u.hostname === '[::1]' ||
      /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/.test(u.hostname)
    ) {
      return false
    }
    const parts = u.hostname.split('.')
    if (
      parts[0] === '10' ||
      (parts[0] === '172' &&
        parseInt(parts[1], 10) >= 16 &&
        parseInt(parts[1], 10) <= 31) ||
      (parts[0] === '192' && parts[1] === '168')
    ) {
      return false
    }
    // Check if protocol is safe
    let safeProtocols = [
      'http:',
      'https:',
      'mailto:',
      'irc:',
      'telnet:',
      'tel:',
      'svn:'
    ]
    if (!safeProtocols.includes(u.protocol)) {
      return false
    }
  } catch (e) {
    return false
  }
  return true
}
Checks if the URL is safe to navigate to. Checks if site exists and if it uses safe protocols.
@param {String} u - The URL to check
@returns {Boolean} - True if the URL is safe to navigate to, false otherwise