mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 03:08:55 -05:00
[Downloader] Add Repo.clean_url and use it in [p]findcog (#3129)
* enhance(downloader): add `Repo.clean_url` and use it in `[p]findcog` * chore(changelog): add towncrier entries
This commit is contained in:
parent
548a50b984
commit
8a90996b36
1
changelog.d/downloader/3129.enhance.rst
Normal file
1
changelog.d/downloader/3129.enhance.rst
Normal file
@ -0,0 +1 @@
|
||||
Use sanitized url (without HTTP Basic Auth fragments) in `[p]findcog` command.
|
||||
1
changelog.d/downloader/3129.misc.rst
Normal file
1
changelog.d/downloader/3129.misc.rst
Normal file
@ -0,0 +1 @@
|
||||
Add `clean_url` property to :class:`redbot.cogs.downloader.repo_manager.Repo` which contains sanitized repo URL (without HTTP Basic Auth).
|
||||
@ -1150,7 +1150,7 @@ class Downloader(commands.Cog):
|
||||
repo_url = (
|
||||
_("Missing from installed repos")
|
||||
if cog_installable.repo is None
|
||||
else cog_installable.repo.url
|
||||
else cog_installable.repo.clean_url
|
||||
)
|
||||
cog_name = cog_installable.name
|
||||
else:
|
||||
|
||||
@ -7,6 +7,7 @@ import pkgutil
|
||||
import shlex
|
||||
import shutil
|
||||
import re
|
||||
import yarl
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
from pathlib import Path
|
||||
from subprocess import run as sp_run, PIPE, CompletedProcess
|
||||
@ -147,6 +148,13 @@ class Repo(RepoJSONMixin):
|
||||
|
||||
self._loop = loop if loop is not None else asyncio.get_event_loop()
|
||||
|
||||
@property
|
||||
def clean_url(self):
|
||||
"""Sanitized repo URL (with removed HTTP Basic Auth)"""
|
||||
url = yarl.URL(self.url)
|
||||
clean_url = url.with_user(None)
|
||||
return clean_url
|
||||
|
||||
@classmethod
|
||||
async def convert(cls, ctx: commands.Context, argument: str) -> Repo:
|
||||
downloader_cog = ctx.bot.get_cog("Downloader")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user