fix: enhance URL building logic in DriverSession with additional test cases

This commit is contained in:
lilong.129
2025-06-28 20:25:28 +08:00
parent 43c82f1ec0
commit a71acffa5b
2 changed files with 41 additions and 6 deletions

View File

@@ -94,6 +94,26 @@ func TestDriverSession_buildURL(t *testing.T) {
urlStr: "users",
want: "http://localhost:8080/api/users",
},
// Reproduction case: base URL with path + absolute path (leading slash)
{
name: "baseUrl with path + absolute path should preserve base path",
baseURL: "http://forward-to-38153:6790/wd/hub",
urlStr: "/session",
want: "http://forward-to-38153:6790/wd/hub/session",
},
// Additional test cases for comprehensive coverage
{
name: "baseUrl with path + absolute path with query params",
baseURL: "http://localhost:8080/api/v1",
urlStr: "/session?timeout=30",
want: "http://localhost:8080/api/v1/session?timeout=30",
},
{
name: "baseUrl with path + absolute path with query params and fragment",
baseURL: "http://localhost:8080/wd/hub",
urlStr: "/session/123?param=value#fragment",
want: "http://localhost:8080/wd/hub/session/123?param=value#fragment",
},
}
for _, tt := range tests {