Automate browser based workflows with AI
Python aiapiautomationbrowserbrowser-automationcomputergptllmplaywrightpowerautomatepuppeteerpythonrpaseleniumvisionworkflow
fix url encoding in the param part (#2520)
Shuchang Zheng62e9d84fd6c3
diff --git a/skyvern/utils/url_validators.py b/skyvern/utils/url_validators.pyindex 8100ac054..f858f34a6 100644--- a/skyvern/utils/url_validators.py+++ b/skyvern/utils/url_validators.py@@ -65,4 +65,5 @@ def encode_url(url: str) -> str:parts = list(urlsplit(url))# Encode the path while preserving "/" and "%"parts[2] = quote(parts[2], safe="/%")+ parts[3] = quote(parts[3], safe="=&/%")return urlunsplit(parts)diff --git a/tests/unit_tests/__init__.py b/tests/unit_tests/__init__.pynew file mode 100644index 000000000..e69de29bbdiff --git a/tests/unit_tests/test_url_validators.py b/tests/unit_tests/test_url_validators.pynew file mode 100644index 000000000..44d05458a--- /dev/null+++ b/tests/unit_tests/test_url_validators.py@@ -0,0 +1,29 @@+from skyvern.utils.url_validators import encode_url+++def test_encode_url_basic():+ """Test basic URL encoding with simple path"""+ url = "https://example.com/path with spaces"+ expected = "https://example.com/path%20with%20spaces"+ assert encode_url(url) == expected+++def test_encode_url_with_query_params():+ """Test URL encoding with query parameters"""+ url = "https://example.com/search?q=hello world&type=test"+ expected = "https://example.com/search?q=hello%20world&type=test"+ assert encode_url(url) == expected+++def test_encode_url_with_special_chars():+ """Test URL encoding with special characters"""+ url = "https://example.com/path/with/special#chars?param=value&other=test@123"+ expected = "https://example.com/path/with/special#chars?param=value&other=test@123"+ assert encode_url(url) == expected+++def test_encode_url_with_pre_encoded_chars():+ """Test URL encoding with pre-encoded characters in query parameters"""+ url = "https://example.com/search?q=hello world&type=test%20test"+ expected = "https://example.com/search?q=hello%20world&type=test%20test"+ assert encode_url(url) == expected