Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Changelog
~~~~~~~~~
- N/A
- treat ``|`` as a stop character on the right side of URL (Jira/Confluence style links) - by rishisy

- 1.9.0 (2024-02-29)
- Adding support for Python 3.12
Expand Down
6 changes: 6 additions & 0 deletions tests/unit/test_find_urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@
),
("bad.email @address.net>", ["bad.email"]),
('[[ "$(giturl)" =~ ^https://gitlab.com ]] echo "found" || echo "didnt', []),
(
"[https://example.com/page|https://example.com/page|smart-link]",
["https://example.com/page", "https://example.com/page"],
),
("[http://example.com|Example]", ["http://example.com"]),
("see example.com|other", ["example.com"]),
],
)
def test_find_urls(urlextract, text, expected):
Expand Down
6 changes: 3 additions & 3 deletions urlextract/urlextract_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,10 @@ def __init__(
self._reload_tlds_from_file()

# general stop characters
general_stop_chars = {'"', "<", ">", ";"}
general_stop_chars = {'"', "<", ">", ";", "|"}
# defining default stop chars left
self._stop_chars_left = set(string.whitespace)
self._stop_chars_left |= general_stop_chars | {"|", "=", "]", ")", "}"}
self._stop_chars_left |= general_stop_chars | {"=", "]", ")", "}"}

# default stop characters on left side from schema
self._stop_chars_left_from_schema = self._stop_chars_left.copy() | {":"}
Expand All @@ -131,7 +131,7 @@ def __init__(
def _get_after_tld_chars(self) -> Set[str]:
"""Initialize after tld characters"""
after_tld_chars = set(string.whitespace)
after_tld_chars |= {"/", '"', "'", "<", ">", "?", ":", ".", ","}
after_tld_chars |= {"/", '"', "'", "<", ">", "?", ":", ".", ",", "|"}
# get left enclosure characters
_, right_enclosure = zip(*self._enclosure)
# add right enclosure characters to be valid after TLD
Expand Down
Loading