fix: update URL regex to strip trailing punctuation

This commit is contained in:
Paul Gauthier (aider) 2024-10-31 14:01:21 -07:00
parent 9a37c0491d
commit da706d9eb8

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]*)")
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