[Downloader] Make Repo.clean_url work with relative urls. (#3142)

* fix(downloader): return string, catch ValueError for relative urls

* chore(changelog): add towncrier entry
This commit is contained in:
jack1142 2019-11-19 19:14:22 +01:00 committed by Michael H
parent ddfabb0c0e
commit 4b62598a3d
2 changed files with 6 additions and 3 deletions

View File

@ -0,0 +1 @@
Make :attr:`redbot.cogs.downloader.repo_manager.Repo.clean_url` work with relative urls. This property uses `str` type now.

View File

@ -149,11 +149,13 @@ class Repo(RepoJSONMixin):
self._loop = loop if loop is not None else asyncio.get_event_loop()
@property
def clean_url(self):
def clean_url(self) -> str:
"""Sanitized repo URL (with removed HTTP Basic Auth)"""
url = yarl.URL(self.url)
clean_url = url.with_user(None)
return clean_url
try:
return url.with_user(None).human_repr()
except ValueError:
return self.url
@classmethod
async def convert(cls, ctx: commands.Context, argument: str) -> Repo: