MCPcopy
hub / github.com/Aider-AI/aider / check_and_open_urls

Method check_and_open_urls

aider/coders/base_coder.py:946–962  ·  view source on GitHub ↗

Check exception for URLs, offer to open in a browser, with user-friendly error msgs.

(self, exc, friendly_msg=None)

Source from the content-addressed store, hash-verified

944 message = self.reflected_message
945
946 def check_and_open_urls(self, exc, friendly_msg=None):
947 """Check exception for URLs, offer to open in a browser, with user-friendly error msgs."""
948 text = str(exc)
949
950 if friendly_msg:
951 self.io.tool_warning(text)
952 self.io.tool_error(f"{friendly_msg}")
953 else:
954 self.io.tool_error(text)
955
956 # Exclude double quotes from the matched URL characters
957 url_pattern = re.compile(r'(https?://[^\s/$.?#].[^\s"]*)')
958 urls = list(set(url_pattern.findall(text))) # Use set to remove duplicates
959 for url in urls:
960 url = url.rstrip(".',\"}") # Added } to the characters to strip
961 self.io.offer_url(url)
962 return urls
963
964 def check_for_urls(self, inp: str) -> List[str]:
965 """Check input for URLs and offer to add them to the chat."""

Callers 1

send_messageMethod · 0.95

Calls 3

tool_warningMethod · 0.45
tool_errorMethod · 0.45
offer_urlMethod · 0.45

Tested by

no test coverage detected