Commits

Peter Nixon committed c05f603

Don't add a period to the end of IP address based urls

Comments (0)

Files changed (1)

bmutils/bmutils.py

                 return self.httphost
             else:
                 # The request is to an IP address, not a hostname
+                ## FIXME: This is broken as o.hostname contains the IP also!
                 self.httphost = o.netloc
         else:
             # The connection was not a valid HTTP request and was bypassed by the proxy
         else:
             no_fetch_extract = tldextract.TLDExtract(fetch=False)
             ext = tldextract.extract(self.url)      # Extract TLD parts
-            self.domainname = '.'.join(ext[1:3])    # rejoin subdomain and domain
-            return self.domainname
+            if ext.tld == '':
+                # There is no TLD so just return domain (Most likely an IP address)
+                return ext.domain
+            else:
+                self.domainname = '.'.join(ext[1:3])    # rejoin subdomain and domain
+                return self.domainname
 
     def run_regex(self, line, process_hostnames=False):
         ''' Try to parse the line with a regex; return True if sucessfull. '''