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

Function correct_url

medium-parser/medium_parser/utils.py:167–192  ·  view source on GitHub ↗
(url: str)

Source from the content-addressed store, hash-verified

165
166
167def correct_url(url: str) -> str:
168 # Workaround for Safari bug. We don't known by what condition this happens, but sometimes we get
169 # some broken URL, for example like "", and all of them based on user-agent comes from Safari browser engine,
170 # from some kinda different platforms like Windows, and that's strange bcz does Windows has Safari browser? lmao
171
172 # TODO: fix
173
174 # unsafari_url = re.sub(r"https?://", DEFAULT_URL_PROTOCOL, url)
175 # logger.debug(f"Is URL broken by Safari bug: {unsafari_url != url}")
176
177 unsafari_url = url
178
179 unquerified_url = unquerify_url(unsafari_url)
180 logger.debug(f"Is URL has query data: {unquerified_url != unsafari_url}")
181
182 unplaginated_url = unplaginate_url(unquerified_url)
183 logger.debug(f"Is URL has plagination: {unplaginated_url != unquerified_url}")
184
185 # parsed_url = urlparse(url)
186 # if not bool(parsed_url.netloc and parsed_url.scheme):
187 # return DEFAULT_PROTOCOL + url
188
189 # if not re.match(r'http[s]?://', url):
190 # url = DEFAULT_PROTOCOL + url
191
192 return url
193
194
195def unplaginate_url(url):

Callers 1

resolve_urlMethod · 0.85

Calls 2

unquerify_urlFunction · 0.85
unplaginate_urlFunction · 0.85

Tested by

no test coverage detected