You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I had code like below in testing where generateRandomName function may return name that contains space. Test misses the URL encoding so it might produce URL like /v1/my-great-api?name=John Doe.
url := fmt.Sprintf("/v1/my-great-api?name=%s", generateRandomName())
r := httptest.NewRequest("GET", url, nil)
What did you see happen?
I got error message like this, which puzzled me for a while
panic: invalid NewRequest arguments; malformed HTTP version "Doe HTTP/1.0"
What did you expect to see?
While this is a user error, it would be helpful to get error message like
invalid URL "/v1/my-great-api?name=John Doe"
I'll be happy to send a PR to update validation logic, just wanted to make sure if this suggested fix makes sense first :)
The text was updated successfully, but these errors were encountered:
Go version
go version go1.22.2 darwin/arm64
Output of
go env
in your module/workspace:What did you do?
I had code like below in testing where
generateRandomName
function may return name that contains space. Test misses the URL encoding so it might produce URL like/v1/my-great-api?name=John Doe
.What did you see happen?
I got error message like this, which puzzled me for a while
What did you expect to see?
While this is a user error, it would be helpful to get error message like
I'll be happy to send a PR to update validation logic, just wanted to make sure if this suggested fix makes sense first :)
The text was updated successfully, but these errors were encountered: