From 003e95ad328dee8ab76b6fafd83e8381b978e0db Mon Sep 17 00:00:00 2001 From: Joe Obarzanek Date: Mon, 4 Nov 2024 16:20:23 -0500 Subject: [PATCH] Fix server check for query --- asyncwhois/query.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/asyncwhois/query.py b/asyncwhois/query.py index bae8807..e204e63 100644 --- a/asyncwhois/query.py +++ b/asyncwhois/query.py @@ -148,6 +148,7 @@ def _do_query( whois_server and whois_server != server and not whois_server.startswith("http") + and not whois_server.startswith("www.") ): # recursive call to find more authoritative server chain = self._do_query( @@ -173,10 +174,12 @@ async def _aio_do_query( # parse response for the referred WHOIS server name whois_server = self._find_match(regex, query_output) whois_server = whois_server.lower() + # check for another legitimate server name if ( whois_server and whois_server != server and not whois_server.startswith("http") + and not whois_server.startswith("www.") ): # recursive call to find the authoritative server chain = await self._aio_do_query( @@ -197,7 +200,8 @@ def __init__( self.server = server @staticmethod - def _get_server_name(tld: str) -> Union[str, None]: + def _get_server_name(domain_name: str) -> Union[str, None]: + tld = domain_name.split(".")[-1] tld_converted = tld.upper().replace("-", "_") for servers in [CountryCodeTLD, GenericTLD, SponsoredTLD]: if hasattr(servers, tld_converted):