fix: improve URL pattern to handle trailing commas in links

This commit is contained in:
Paul Gauthier 2024-10-31 14:01:41 -07:00 committed by Paul Gauthier (aider)
parent fea7134064
commit 15c62e3e43

View file

@ -793,7 +793,7 @@ class Coder:
def check_and_open_urls(self, text: str) -> List[str]:
"""Check text for URLs and offer to open them in a browser."""
url_pattern = re.compile(r"(https?://[^\s/$.?#].[^\s]*?)([.']*$|[.'\s])")
url_pattern = re.compile(r"(https?://[^\s/$.?#].[^\s]*?)([.']*$|[.',\s])")
# ai strip trailing . or ' from the url!
urls = list(set(url_pattern.findall(text))) # Use set to remove duplicates