Peter Nixon avatar 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. '''
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.