From 014fd671f16366d54b93975fb84229c3845d1499 Mon Sep 17 00:00:00 2001 From: Jaex Date: Sun, 6 Jan 2019 15:00:15 +0300 Subject: [PATCH] If there is no value in query string then don't add = after key --- ShareX.HelpersLib/Helpers/URLHelpers.cs | 31 ++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/ShareX.HelpersLib/Helpers/URLHelpers.cs b/ShareX.HelpersLib/Helpers/URLHelpers.cs index 8f34c6d4f..40d924996 100644 --- a/ShareX.HelpersLib/Helpers/URLHelpers.cs +++ b/ShareX.HelpersLib/Helpers/URLHelpers.cs @@ -444,7 +444,36 @@ public static string CreateQueryString(Dictionary 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 pairs = new List(); + + foreach (KeyValuePair 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 "";