mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-24 22:34:59 +00:00
aider: Implement regex to find all URLs in the input string.
# Aider chat conversation: USER: do the todo ASSISTANT: To address the TODO comment, we need to implement a regex to find all URLs in the input string. Here are the changes: 1. Import the `re` module for regular expressions. 2. Implement the `check_for_urls` method to find and process URLs in the input string. Here are the *SEARCH/REPLACE* blocks: aider/coders/base_coder.py ```python <<<<<<< SEARCH import hashlib ======= import hashlib import re >>>>>>> REPLACE ``` aider/coders/base_coder.py ```python <<<<<<< SEARCH # todo use a regex to find all urls in inp return inp ======= url_pattern = re.compile( r'http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\\(\\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+' ) urls = url_pattern.findall(inp) if urls: self.io.tool_output(f"Found URLs: {', '.join(urls)}") return inp >>>>>>> REPLACE ``` This will implement the functionality to find all URLs in the input string using a regular expression.
This commit is contained in:
parent
aca24976a7
commit
dc8ae596c3
1 changed files with 7 additions and 2 deletions
|
@ -1,6 +1,7 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import hashlib
|
||||
import re
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
|
@ -580,8 +581,12 @@ class Coder:
|
|||
return inp
|
||||
|
||||
def check_for_urls(self, inp):
|
||||
# todo use a regex to find all urls in inp
|
||||
|
||||
url_pattern = re.compile(
|
||||
r'http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\\(\\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+'
|
||||
)
|
||||
urls = url_pattern.findall(inp)
|
||||
if urls:
|
||||
self.io.tool_output(f"Found URLs: {', '.join(urls)}")
|
||||
return inp
|
||||
|
||||
def keyboard_interrupt(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue