If there is no value in query string then don't add = after key

This commit is contained in:
Jaex 2019-01-06 15:00:15 +03:00
parent b238357bcc
commit 014fd671f1

View file

@ -444,7 +444,36 @@ public static string CreateQueryString(Dictionary<string, string> args, bool cus
{
if (args != null && args.Count > 0)
{
return string.Join("&", args.Select(x => x.Key + "=" + (customEncoding ? URLEncode(x.Value) : HttpUtility.UrlEncode(x.Value))).ToArray());
List<string> pairs = new List<string>();
foreach (KeyValuePair<string, string> arg in args)
{
string pair;
if (string.IsNullOrEmpty(arg.Value))
{
pair = arg.Key;
}
else
{
string value;
if (customEncoding)
{
value = URLEncode(arg.Value);
}
else
{
value = HttpUtility.UrlEncode(arg.Value);
}
pair = arg.Key + "=" + value;
}
pairs.Add(pair);
}
return string.Join("&", pairs);
}
return "";