MCPcopy Create free account
hub / github.com/Freedium-cfd/web / unquerify_url

Function unquerify_url

medium-parser/medium_parser/utils.py:139–156  ·  view source on GitHub ↗

Sanitizes a URL by removing all query parameters. Args: url: The URL to sanitize. Returns: A sanitized URL.

(url: str)

Source from the content-addressed store, hash-verified

137
138
139def unquerify_url(url: str) -> str:
140 """
141 Sanitizes a URL by removing all query parameters.
142
143 Args:
144 url: The URL to sanitize.
145
146 Returns:
147 A sanitized URL.
148 """
149
150 parsed_url = urllib.parse.urlparse(url)
151 query = parsed_url.query
152 if query:
153 parsed_url = parsed_url._replace(query="")
154
155 sanitized_url = urllib.parse.urlunparse(parsed_url)
156 return sanitized_url.removesuffix("/")
157
158
159@lru_cache(maxsize=500)

Callers 1

correct_urlFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected