MCPcopy Create free account
hub / github.com/psf/cachecontrol / _urlnorm

Method _urlnorm

cachecontrol/controller.py:66–83  ·  view source on GitHub ↗

Normalize the URL to create a safe key for the cache

(cls, uri: str)

Source from the content-addressed store, hash-verified

64
65 @classmethod
66 def _urlnorm(cls, uri: str) -> str:
67 """Normalize the URL to create a safe key for the cache"""
68 (scheme, authority, path, query, fragment) = parse_uri(uri)
69 if not scheme or not authority:
70 raise Exception("Only absolute URIs are allowed. uri = %s" % uri)
71
72 scheme = scheme.lower()
73 authority = authority.lower()
74
75 if not path:
76 path = "/"
77
78 # Could do syntax based normalization of the URI before
79 # computing the digest. See Section 6.2.2 of Std 66.
80 request_uri = query and "?".join([path, query]) or path
81 defrag_uri = scheme + "://" + authority + request_uri
82
83 return defrag_uri
84
85 @classmethod
86 def cache_url(cls, uri: str) -> str:

Callers 1

cache_urlMethod · 0.80

Calls 1

parse_uriFunction · 0.85

Tested by

no test coverage detected