MCPcopy Index your code
hub / github.com/RustPython/RustPython / _urlsplit

Function _urlsplit

Lib/urllib/parse.py:499–531  ·  view source on GitHub ↗
(url, scheme=None, allow_fragments=True)

Source from the content-addressed store, hash-verified

497 return _coerce_result(v)
498
499def _urlsplit(url, scheme=None, allow_fragments=True):
500 # Only lstrip url as some applications rely on preserving trailing space.
501 # (https://url.spec.whatwg.org/#concept-basic-url-parser would strip both)
502 url = url.lstrip(_WHATWG_C0_CONTROL_OR_SPACE)
503 for b in _UNSAFE_URL_BYTES_TO_REMOVE:
504 url = url.replace(b, "")
505 if scheme is not None:
506 scheme = scheme.strip(_WHATWG_C0_CONTROL_OR_SPACE)
507 for b in _UNSAFE_URL_BYTES_TO_REMOVE:
508 scheme = scheme.replace(b, "")
509
510 allow_fragments = bool(allow_fragments)
511 netloc = query = fragment = None
512 i = url.find(':')
513 if i > 0 and url[0].isascii() and url[0].isalpha():
514 for c in url[:i]:
515 if c not in scheme_chars:
516 break
517 else:
518 scheme, url = url[:i].lower(), url[i+1:]
519 if url[:2] == '//':
520 netloc, url = _splitnetloc(url, 2)
521 if (('[' in netloc and ']' not in netloc) or
522 (']' in netloc and '[' not in netloc)):
523 raise ValueError("Invalid IPv6 URL")
524 if '[' in netloc and ']' in netloc:
525 _check_bracketed_netloc(netloc)
526 if allow_fragments and '#' in url:
527 url, fragment = url.split('#', 1)
528 if '?' in url:
529 url, query = url.split('?', 1)
530 _checknetloc(netloc)
531 return (scheme, netloc, url, query, fragment)
532
533def urlunparse(components):
534 """Put a parsed URL back together again. This may result in a

Callers 4

_urlparseFunction · 0.85
urlsplitFunction · 0.85
urljoinFunction · 0.85
urldefragFunction · 0.85

Calls 11

_splitnetlocFunction · 0.85
_check_bracketed_netlocFunction · 0.85
_checknetlocFunction · 0.85
lstripMethod · 0.45
replaceMethod · 0.45
stripMethod · 0.45
findMethod · 0.45
isasciiMethod · 0.45
isalphaMethod · 0.45
lowerMethod · 0.45
splitMethod · 0.45

Tested by

no test coverage detected