Only add a ? when query string is nonempty (#1589)

* Only add a ? when query string is nonempty

* Adds changelog entry
This commit is contained in:
Ian Shipman 2022-05-16 09:50:10 -05:00 committed by GitHub
parent 8ef5021a5f
commit 1fba9dc604
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

2
changelog.d/1589 Normal file
View File

@ -0,0 +1,2 @@
synopsis: Only include question mark for nonempty query strings
prs: 1589

View File

@ -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