Fix .git ignore entry suppressing redirects for GitHub subdomains (#885)
This commit is contained in:
+1
-1
@@ -28,4 +28,4 @@
|
||||
# ├── test_summarize_pr.py
|
||||
# └── ...
|
||||
|
||||
__version__ = "0.3.14"
|
||||
__version__ = "0.3.15"
|
||||
|
||||
@@ -147,7 +147,6 @@ REDIRECT_START_IGNORE_LIST = frozenset(
|
||||
"ultralytics.com/assets",
|
||||
"app.gong.io/call?",
|
||||
"docs.openvino.ai",
|
||||
".git",
|
||||
"/raw/", # GitHub images
|
||||
".slack.com", # Slack URLs to private channels
|
||||
"https://maps.app.goo.gl/nxB8YygRQeXSS9G18", # Ultralytics Madrid office - Cra de San Jeronimo 15
|
||||
@@ -281,6 +280,7 @@ def allow_redirect(start="", end=""):
|
||||
return (
|
||||
end
|
||||
and end.startswith("https://")
|
||||
and not start_lower.endswith(".git") # git clone URLs, i.e. https://github.com/org/repo.git
|
||||
and all(item not in end_lower for item in REDIRECT_END_IGNORE_LIST)
|
||||
and all(item not in start_lower for item in REDIRECT_START_IGNORE_LIST)
|
||||
)
|
||||
|
||||
@@ -41,12 +41,19 @@ def test_allow_redirect():
|
||||
# Should not allow - start ignores
|
||||
assert not allow_redirect("https://youtu.be/xyz", "https://youtube.com")
|
||||
|
||||
# Should not allow - git clone URLs
|
||||
assert not allow_redirect("https://github.com/ultralytics/ultralytics.git", "https://github.com/ultralytics/yolo")
|
||||
|
||||
# Should not allow - end ignores
|
||||
assert not allow_redirect("https://example.com", "https://example.com/404")
|
||||
|
||||
# Empty end URL
|
||||
assert not allow_redirect("https://example.com", "")
|
||||
|
||||
# Should allow - GitHub subdomains are not git clone URLs
|
||||
assert allow_redirect("https://docs.github.com/en/old", "https://docs.github.com/en/new")
|
||||
assert allow_redirect("https://gist.github.com/user/abc", "https://gist.github.com/user/def")
|
||||
|
||||
|
||||
@patch("requests.get")
|
||||
def test_brave_search(mock_get):
|
||||
|
||||
Reference in New Issue
Block a user