MCPcopy
hub / github.com/encode/starlette / make_absolute_url

Method make_absolute_url

starlette/datastructures.py:189–202  ·  view source on GitHub ↗
(self, base_url: str | URL)

Source from the content-addressed store, hash-verified

187 self.host = host
188
189 def make_absolute_url(self, base_url: str | URL) -> URL:
190 if isinstance(base_url, str):
191 base_url = URL(base_url)
192 if self.protocol:
193 scheme = {
194 "http": {True: "https", False: "http"},
195 "websocket": {True: "wss", False: "ws"},
196 }[self.protocol][base_url.is_secure]
197 else:
198 scheme = base_url.scheme
199
200 netloc = self.host or base_url.netloc
201 path = base_url.path.rstrip("/") + str(self)
202 return URL(scheme=scheme, netloc=netloc, path=path)
203
204
205class Secret:

Callers 4

url_forMethod · 0.80
test_url_forFunction · 0.80
test_host_reverse_urlsFunction · 0.80

Calls 1

URLClass · 0.85

Tested by 3

test_url_forFunction · 0.64
test_host_reverse_urlsFunction · 0.64