Skip to content

Commit 26696b6

Browse files
author
Oriental Sensation
committed
Only add the query string if it's not empty and it's not equal to '?'
1 parent c53f350 commit 26696b6

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

library/src/main/java/com/loopj/android/http/AsyncHttpClient.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -938,11 +938,15 @@ public static String getUrlWithQueryString(boolean shouldEncodeUrl, String url,
938938
url = url.replace(" ", "%20");
939939

940940
if (params != null) {
941-
String paramString = params.getParamString();
942-
if (!url.contains("?")) {
943-
url += "?" + paramString;
944-
} else {
945-
url += "&" + paramString;
941+
// Construct the query string and trim it, in case it
942+
// includes any excessive white spaces.
943+
String paramString = params.getParamString().trim();
944+
945+
// Only add the query string if it isn't empty and it
946+
// isn't equal to '?'.
947+
if (!paramString.equals("") && !paramString.equals("?")) {
948+
url += url.contains("?") ? "&" : "?";
949+
url += paramString;
946950
}
947951
}
948952

0 commit comments

Comments
 (0)