MCPcopy Index your code
hub / github.com/mitmproxy/mitmproxy / colorize_host

Function colorize_host

mitmproxy/tools/console/common.py:245–271  ·  view source on GitHub ↗
(host: str)

Source from the content-addressed store, hash-verified

243
244
245def colorize_host(host: str):
246 if not host:
247 return []
248
249 tld = get_tld(host)
250 sld = get_sld(host)
251
252 attr: list = []
253
254 tld_size = len(tld)
255 sld_size = len(sld) - tld_size
256
257 for letter in reversed(range(len(host))):
258 character = host[letter]
259 if tld_size > 0:
260 style = "url_domain"
261 tld_size -= 1
262 elif tld_size == 0:
263 style = "text"
264 tld_size -= 1
265 elif sld_size > 0:
266 sld_size -= 1
267 style = "url_extension"
268 else:
269 style = "text"
270 rle_append_beginning_modify(attr, (style, len(character.encode())))
271 return attr
272
273
274def colorize_req(s: str):

Callers 2

format_http_flow_tableFunction · 0.85
format_dns_flowFunction · 0.85

Calls 2

encodeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…