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

Function _checknetloc

Lib/urllib/parse.py:424–440  ·  view source on GitHub ↗
(netloc)

Source from the content-addressed store, hash-verified

422 return url[start:delim], url[delim:] # return (domain, rest)
423
424def _checknetloc(netloc):
425 if not netloc or netloc.isascii():
426 return
427 # looking for characters like \u2100 that expand to 'a/c'
428 # IDNA uses NFKC equivalence, so normalize for this check
429 import unicodedata
430 n = netloc.replace('@', '') # ignore characters already included
431 n = n.replace(':', '') # but not the surrounding text
432 n = n.replace('#', '')
433 n = n.replace('?', '')
434 netloc2 = unicodedata.normalize('NFKC', n)
435 if n == netloc2:
436 return
437 for c in '/?#@:':
438 if c in netloc2:
439 raise ValueError("netloc '" + netloc + "' contains invalid " +
440 "characters under NFKC normalization")
441
442def _check_bracketed_netloc(netloc):
443 # Note that this function must mirror the splitting

Callers 1

_urlsplitFunction · 0.85

Calls 3

isasciiMethod · 0.45
replaceMethod · 0.45
normalizeMethod · 0.45

Tested by

no test coverage detected