Update the plugin git url pattern (#1047)

This commit is contained in:
Wu Clan
2026-01-27 17:06:43 +08:00
committed by GitHub
parent d397a0d985
commit ac19f8480f
2 changed files with 3 additions and 3 deletions

View File

@@ -118,7 +118,7 @@ async def install_git_plugin(repo_url: str) -> str:
"""
match = is_git_url(repo_url)
if not match:
raise errors.RequestError(msg='Git 仓库地址格式非法')
raise errors.RequestError(msg='Git 仓库地址格式非法,仅支持 HTTP/HTTPS 协议')
repo_name = match.group('repo')
path = anyio.Path(PLUGIN_DIR / repo_name)
if await path.exists():

View File

@@ -36,12 +36,12 @@ def is_phone(number: str) -> re.Match[str]:
def is_git_url(url: str) -> re.Match[str]:
"""
检查 git URL 格式
检查 git URL 格式(仅允许 HTTP/HTTPS 协议)
:param url: 待检查的 URL
:return:
"""
git_pattern = r'^(?!(git\+ssh|ssh)://|git@)(?P<scheme>git|https?|file)://(?P<host>[^/]*)(?P<path>(?:/[^/]*)*/)(?P<repo>[^/]+?)(?:\.git)?$'
git_pattern = r'^(?P<scheme>https?)://(?P<host>[^/]*)(?P<path>(?:/[^/]*)*/)(?P<repo>[^/]+?)(?:\.git)?$'
return match_string(git_pattern, url)