MCPcopy Create free account
hub / github.com/microsoft/playwright-python / resolve_base_url

Function resolve_base_url

playwright/_impl/_helper.py:248–265  ·  view source on GitHub ↗
(
    base_url: Optional[str], given_url: str
)

Source from the content-addressed store, hash-verified

246
247
248def resolve_base_url(
249 base_url: Optional[str], given_url: str
250) -> Tuple[str, Optional[str]]:
251 try:
252 url = nodelike_urlparse(
253 urljoin(base_url if base_url is not None else "", given_url)
254 )
255 resolved = urlunparse(url)
256 # Schema and domain are case-insensitive.
257 hostname_port = (
258 url.hostname or ""
259 ) # can't use parsed.netloc because it includes userinfo (username:password)
260 if url.port:
261 hostname_port += f":{url.port}"
262 case_insensitive_prefix = f"{url.scheme}://{hostname_port}"
263 return resolved, case_insensitive_prefix
264 except Exception:
265 return given_url, None
266
267
268def nodelike_urlparse(url: str) -> ParseResult:

Callers 1

resolve_glob_baseFunction · 0.85

Calls 1

nodelike_urlparseFunction · 0.85

Tested by

no test coverage detected