code: protected function chompHost(&$url)
      {
          if (preg_match('!^(//)(.*?)(/.*|\?.*|#.*|$)!', $url, $matches)) {
              $url = $matches[3];
  
              return $matches[2];
          }
          if (preg_match('!(.*?)(\.\./|\./|/|\?|#|$)(.*)!', $url, $matches)) {
              $tlds = self::getAllTopLevelDomains();
              if (preg_match('/[a-z0-9\-]+\.(' . $tlds . ')/i', $matches[1])) {
                  $url = $matches[2] . $matches[3];
  
                  return $matches[1];
              } elseif (preg_match('/[a-z0-9\-]+\.[a-z0-9\-]+\.[a-z0-9\-]+/i', $matches[1])) {
                  $url = $matches[2] . $matches[3];
  
                  return $matches[1];
              }
          }
  
          return false;
      }
docs: Extracts the host part of an incoming URL. Includes the port number part. Will extract the
  host if it starts with // or it has a top level domain or it has at least two dots.
  
  @param string $url    URL so far. The host will be removed.
  
  @return string        Host part guess or false.