Skip to content

Only add a ? when query string is nonempty #1589

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelog.d/1589
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
synopsis: Only include question mark for nonempty query strings
prs: 1589
3 changes: 2 additions & 1 deletion servant-client/src/Servant/Client/Internal/HttpClient.hs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,8 @@ defaultMakeClientRequest burl r = Client.defaultRequest
Https -> True

-- Query string builder which does not do any encoding
buildQueryString = ("?" <>) . foldl' addQueryParam mempty
buildQueryString [] = mempty
buildQueryString qps = "?" <> foldl' addQueryParam mempty qps

addQueryParam qs (k, v) =
qs <> (if BS.null qs then mempty else "&") <> urlEncode True k <> foldMap ("=" <>) v
Expand Down