108 path += "/" |
108 path += "/" |
109 port = urlParts.port |
109 port = urlParts.port |
110 host = host.strip(".") |
110 host = host.strip(".") |
111 host = re.sub(r"\.+", ".", host).lower() |
111 host = re.sub(r"\.+", ".", host).lower() |
112 if host.isdigit(): |
112 if host.isdigit(): |
113 with contextlib.suppress(Exception): |
113 with contextlib.suppress(OSError): |
114 host = socket.inet_ntoa(struct.pack("!I", int(host))) |
114 host = socket.inet_ntoa(struct.pack("!I", int(host))) |
115 if host.startswith("0x") and "." not in host: |
115 if host.startswith("0x") and "." not in host: |
116 with contextlib.suppress(Exception): |
116 with contextlib.suppress(OSError): |
117 host = socket.inet_ntoa(struct.pack("!I", int(host, 16))) |
117 host = socket.inet_ntoa(struct.pack("!I", int(host, 16))) |
118 quotedPath = quote(path) |
118 quotedPath = quote(path) |
119 quotedHost = quote(host) |
119 quotedHost = quote(host) |
120 if port is not None: |
120 if port is not None: |
121 quotedHost = "{0}:{1}".format(quotedHost, port) |
121 quotedHost = "{0}:{1}".format(quotedHost, port) |