MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / join_host_port

Function join_host_port

py/selenium/webdriver/common/utils.py:97–109  ·  view source on GitHub ↗

Joins a hostname and port together. This is a minimal implementation intended to cope with IPv6 literals. For example, _join_host_port('::1', 80) == '[::1]:80'. Args: host: hostname or IP port: port number

(host: str, port: int)

Source from the content-addressed store, hash-verified

95
96
97def join_host_port(host: str, port: int) -> str:
98 """Joins a hostname and port together.
99
100 This is a minimal implementation intended to cope with IPv6 literals. For
101 example, _join_host_port('::1', 80) == '[::1]:80'.
102
103 Args:
104 host: hostname or IP
105 port: port number
106 """
107 if ":" in host and not host.startswith("["):
108 return f"[{host}]:{port}"
109 return f"{host}:{port}"
110
111
112def is_connectable(port: int, host: str | None = "localhost") -> bool:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected