Skip to content

Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.

preload url fix punctuation

Magnus Müller2246231cfc5e
diff --git a/browser_use/agent/service.py b/browser_use/agent/service.py
index 9461b21d4..4a1658503 100644
--- a/browser_use/agent/service.py
+++ b/browser_use/agent/service.py
@@ -1205,6 +1205,8 @@ class Agent(Generic[Context, AgentStructuredOutput]):
match = re.search(pattern, task)
if match:
url = match.group(0)
+ # Remove trailing punctuation that's not part of URLs
+ url = re.sub(r'[.,;:!?]+$', '', url)
# Add https:// if missing
if not url.startswith(('http://', 'https://')):
url = 'https://' + url