From f3047e398bb598592bd4022c2e41dd6f3936efd7 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Sun, 13 Apr 2025 03:21:35 +0200 Subject: [PATCH] Expand URL_IGNORE_LIST (#409) Co-authored-by: UltralyticsAssistant --- actions/__init__.py | 2 +- actions/utils/common_utils.py | 77 ++++++++++++++++++----------------- tests/test_urls.py | 2 +- 3 files changed, 41 insertions(+), 40 deletions(-) diff --git a/actions/__init__.py b/actions/__init__.py index d66fd53..b195891 100644 --- a/actions/__init__.py +++ b/actions/__init__.py @@ -22,4 +22,4 @@ # ├── test_summarize_pr.py # └── ... -__version__ = "0.0.64" +__version__ = "0.0.65" diff --git a/actions/utils/common_utils.py b/actions/utils/common_utils.py index cdeecb9..4060aab 100644 --- a/actions/utils/common_utils.py +++ b/actions/utils/common_utils.py @@ -56,45 +56,46 @@ URL_IGNORE_LIST = { # use a set (not frozenset) to update with possible private "storage.googleapis.com", # private GCS buckets "{", # possible Python fstring "(", # breaks pattern matches - "api", # ignore api endpoints -} -REDIRECT_IGNORE_LIST = { - "{", # possible f-string - "}", # possible f-string - "/es/", - "/us/", - "en-us", - "es-es", - "/latest/", - "/2022/", - "/2023/", - "/2024/", - "/2025/", - "/2026/", - "/2027/", - "/2028/", - "/2029/", - "/2030/", - "credential", - "login", - "consent", - "verify", - "badge", - "shields.io", - "bit.ly", - "ow.ly", - "https://youtu.be/", - "latex.codecogs.com", - "svg.image", - "?view=azureml", - "ultralytics.com/actions", - "ultralytics.com/bilibili", - "ultralytics.com/images", - "app.gong.io/call?", - "https://code.visualstudio.com/", # errors - "?rdt=", # problems with reddit redirecting to https://www.reddit.com/r/ultralytics/?rdt=48616 - "objects.githubusercontent.com", # Prevent replacement with temporary signed GitHub asset URLs + "api.", # ignore api endpoints } +REDIRECT_IGNORE_LIST = frozenset( + { + "{", # possible f-string + "}", # possible f-string + "/es/", + "/us/", + "en-us", + "es-es", + "/latest/", + ":text", # ignore text-selection links due to parsing complications + ":443", # https://getcruise.com/ -> https://www.gm.com:443/innovation/path-to-autonomous + "404", + "notfound", + "unsupported", # https://labs.google/fx/tools/video-fx/unsupported-country + "authorize", # nature articles like https://idp.nature.com/authorize?response_type=cookie&client... + "credential", + "login", + "consent", + "verify", + "badge", + "shields.io", + "bit.ly", + "ow.ly", + "https://youtu.be/", + "latex.codecogs.com", + "svg.image", + "?view=azureml", + "?utm_", + "redirect", + "ultralytics.com/actions", + "ultralytics.com/bilibili", + "ultralytics.com/images", + "app.gong.io/call?", + "https://code.visualstudio.com/", # errors + "?rdt=", # problems with reddit redirecting to https://www.reddit.com/r/ultralytics/?rdt=48616 + "objects.githubusercontent.com", # Prevent replacement with temporary signed GitHub asset URLs + } +) URL_PATTERN = re.compile( r"\[([^]]+)]\(([^)]+)\)" # Matches Markdown links [text](url) r"|" diff --git a/tests/test_urls.py b/tests/test_urls.py index d3a1cc4..53319d7 100644 --- a/tests/test_urls.py +++ b/tests/test_urls.py @@ -78,7 +78,7 @@ def test_markdown_links(verbose): def test_mixed_formats(verbose): """Tests URL detection in mixed text formats (HTML, Markdown, plain text) using check_links_in_string.""" text = "A link and [markdown](https://2.org/) and https://3.net" - result, urls = check_links_in_string(text, return_bad=True) + result, urls = check_links_in_string(text, verbose, return_bad=True) assert result is False assert set(urls) == {"https://1.com", "https://3.net"}