(s: str)
| 272 | |
| 273 | |
| 274 | def colorize_req(s: str): |
| 275 | path = s.split("?", 2)[0] |
| 276 | i_query = len(path) |
| 277 | i_last_slash = path.rfind("/") |
| 278 | i_ext = path[i_last_slash + 1 :].rfind(".") |
| 279 | i_ext = i_last_slash + i_ext if i_ext >= 0 else len(s) |
| 280 | in_val = False |
| 281 | attr: list = [] |
| 282 | for i in range(len(s)): |
| 283 | c = s[i] |
| 284 | if ( |
| 285 | (i < i_query and c == "/") |
| 286 | or (i < i_query and i > i_last_slash and c == ".") |
| 287 | or (i == i_query) |
| 288 | ): |
| 289 | a = "url_punctuation" |
| 290 | elif i > i_query: |
| 291 | if in_val: |
| 292 | if c == "&": |
| 293 | in_val = False |
| 294 | a = "url_punctuation" |
| 295 | else: |
| 296 | a = "url_query_value" |
| 297 | else: |
| 298 | if c == "=": |
| 299 | in_val = True |
| 300 | a = "url_punctuation" |
| 301 | else: |
| 302 | a = "url_query_key" |
| 303 | elif i > i_ext: |
| 304 | a = "url_extension" |
| 305 | elif i > i_last_slash: |
| 306 | a = "url_filename" |
| 307 | else: |
| 308 | a = "text" |
| 309 | urwid.util.rle_append_modify(attr, (a, len(c.encode()))) |
| 310 | return attr |
| 311 | |
| 312 | |
| 313 | def format_http_content_type(content_type: str) -> tuple[str, str]: |
no test coverage detected
searching dependent graphs…