private boolean matchDomain(String testDomain,String tailDomain){
  if (!testDomain.endsWith(tailDomain)) {
    return false;
  }
  if (testDomain.length() == tailDomain.length()) {
    return true;
  }
  if (tailDomain.charAt(0) == '.') {
    return true;
  }
  return testDomain.charAt(testDomain.length() - tailDomain.length() - 1) == '.';
}

private boolean matchDomain ( String testDomain , String tailDomain ) { if ( ! testDomain . endsWith ( tailDomain ) ) { return false ; } if ( testDomain . length ( ) == tailDomain . length ( ) ) { return true ; } if ( tailDomain . charAt ( 0 ) == '.' ) { return true ; } return testDomain . charAt ( testDomain . length ( ) - tailDomain . length ( ) - 1 ) == '.' ; }
returns true if the full domain ' s final segments match the tail domain .
