private RefererLookup lookupReferer(String refererHost,String refererPath,Boolean includePath){
  RefererLookup referer=(includePath) ? referers.get(refererHost + refererPath) : referers.get(refererHost);
  if (includePath && referer == null) {
    final String[] pathElements=refererPath.split("/");
    if (pathElements.length > 1) {
      referer=referers.get(refererHost + "/" + pathElements[1]);
    }
  }
  if (referer == null) {
    final int idx=refererHost.indexOf('.');
    if (idx == -1) {
      return null;
    }
 else {
      return lookupReferer(refererHost.substring(idx + 1),refererPath,includePath);
    }
  }
 else {
    return referer;
  }
}

private RefererLookup lookupReferer ( String refererHost , String refererPath , Boolean includePath ) { RefererLookup referer = ( includePath ) ? referers . get ( refererHost + refererPath ) : referers . get ( refererHost ) ; if ( includePath && referer == null ) { final String [ ] pathElements = refererPath . split ( "/" ) ; if ( pathElements . length > 1 ) { referer = referers . get ( refererHost + "/" + pathElements [ 1 ] ) ; } } if ( referer == null ) { final int idx = refererHost . indexOf ( '.' ) ; if ( idx == - 1 ) { return null ; } else { return lookupReferer ( refererHost . substring ( idx + 1 ) , refererPath , includePath ) ; } } else { return referer ; } }
recursive function to lookup a host ( or partial host ) in our referers map . < p / > first check the host , then the host + full path , then the host + one - level path . < p / > if not found , remove one subdomain - level off the front of the host and try again .
