MCPcopy Index your code
hub / github.com/python/cpython / _checknetloc

Function _checknetloc

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

Source from the content-addressed store, hash-verified

507 return url[start:delim], url[delim:] # return (domain, rest)
508
509def _checknetloc(netloc):
510 if not netloc or netloc.isascii():
511 return
512 # looking for characters like \u2100 that expand to 'a/c'
513 # IDNA uses NFKC equivalence, so normalize for this check
514 import unicodedata
515 n = netloc.replace('@', '') # ignore characters already included
516 n = n.replace(':', '') # but not the surrounding text
517 n = n.replace('#', '')
518 n = n.replace('?', '')
519 netloc2 = unicodedata.normalize('NFKC', n)
520 if n == netloc2:
521 return
522 for c in '/?#@:':
523 if c in netloc2:
524 raise ValueError("netloc '" + netloc + "' contains invalid " +
525 "characters under NFKC normalization")
526
527def _check_bracketed_netloc(netloc):
528 # Note that this function must mirror the splitting

Callers 1

_urlsplitFunction · 0.85

Calls 3

isasciiMethod · 0.80
replaceMethod · 0.45
normalizeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…