Skip to content

Commit

Permalink
Only add a ? when query string is nonempty (#1589)
Browse files Browse the repository at this point in the history
* Only add a ? when query string is nonempty

* Adds changelog entry
  • Loading branch information
GambolingPangolin committed May 16, 2022
1 parent 8ef5021 commit 1fba9dc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
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

0 comments on commit 1fba9dc

Please sign in to comment.