Skip to content

Commit 362c027

Browse files
committed
Remove test data
1 parent e07d474 commit 362c027

File tree

1 file changed

+4
-28
lines changed

1 file changed

+4
-28
lines changed

backend/utils/re_verify.py

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def search_string(pattern: str, text: str) -> re.Match[str] | None:
1212
:return:
1313
"""
1414
if not pattern or not text:
15-
return
15+
return None
1616

1717
result = re.search(pattern, text)
1818
return result
@@ -27,7 +27,7 @@ def match_string(pattern: str, text: str) -> re.Match[str] | None:
2727
:return:
2828
"""
2929
if not pattern or not text:
30-
return
30+
return None
3131

3232
result = re.match(pattern, text)
3333
return result
@@ -41,7 +41,7 @@ def is_phone(number: str) -> re.Match[str] | None:
4141
:return:
4242
"""
4343
if not number:
44-
return
44+
return None
4545

4646
phone_pattern = r'^1[3-9]\d{9}$'
4747
return match_string(phone_pattern, number)
@@ -55,31 +55,7 @@ def is_git_url(url: str) -> re.Match[str] | None:
5555
:return:
5656
"""
5757
if not url:
58-
return
58+
return None
5959

6060
git_pattern = r'^(?!(git\+ssh|ssh)://|git@)(?P<scheme>git|https?|file)://(?P<host>[^/]*)(?P<path>(?:/[^/]*)*/)(?P<repo>[^/]+?)(?:\.git)?$'
6161
return match_string(git_pattern, url)
62-
63-
64-
if __name__ == '__main__':
65-
test_urls = [
66-
# 合法协议地址 (git/http/https/file)
67-
'git://github.com/user/repo.git',
68-
'git://gitlab.com/group/project.git',
69-
'git://example.com:8080/custom/repo.git', # 带端口
70-
'http://github.com/user/repo.git',
71-
'https://gitlab.com/group/project.git',
72-
'http://example.com:8080/custom/repo.git',
73-
'file:///path/to/local/repo', # Unix路径
74-
'file:///C:/Projects/repo', # Windows路径
75-
'https://github.com/user/repo.with.dots', # 特殊字符
76-
# 无效协议地址 (应被正则排除)
77-
'git://host.com', # 最小格式(无路径)
78-
'[email protected]:user/repo.git', # SSH格式
79-
'ssh://[email protected]/user/repo.git',
80-
'git+ssh://[email protected]/user/repo.git',
81-
'github.com/user/repo.git', # 无协议
82-
'ftp://example.com/repo.git', # 非法协议
83-
]
84-
for url in test_urls:
85-
print(bool(is_git_url(url)))

0 commit comments

Comments
 (0)