Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/mdurl/_format.py: 22%
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1from __future__ import annotations
3TYPE_CHECKING = False
4if TYPE_CHECKING:
5 from mdurl._url import URL
8def format(url: URL) -> str: # noqa: A001
9 result = ""
11 result += url.protocol or ""
12 result += "//" if url.slashes else ""
13 result += url.auth + "@" if url.auth else ""
15 if url.hostname and ":" in url.hostname:
16 # ipv6 address
17 result += "[" + url.hostname + "]"
18 else:
19 result += url.hostname or ""
21 result += ":" + url.port if url.port else ""
22 result += url.pathname or ""
23 result += url.search or ""
24 result += url.hash or ""
26 return result