mirror of
https://github.com/fastapi-practices/fastapi_best_architecture.git
synced 2026-03-13 09:31:31 +08:00
Update the plugin git url pattern (#1047)
This commit is contained in:
@@ -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():
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user