This commit also adds unit tests.
refs #5706
m_Query = query;
}
+void Url::SetArrayFormatUseBrackets(bool useBrackets)
+{
+ m_ArrayFormatUseBrackets = useBrackets;
+}
+
void Url::AddQueryElement(const String& name, const String& value)
{
auto it = m_Query.find(name);
temp += "&";
temp += key;
- if (kv.second.size() > 1)
- temp += "[]";
+
+ if (m_ArrayFormatUseBrackets) {
+ if (kv.second.size() > 1)
+ temp += "[]";
+ }
if (!s.IsEmpty())
temp += "=" + Utility::EscapeString(s, ACQUERY_ENCODE, false);
void SetPort(const String& port);
void SetPath(const std::vector<String>& path);
void SetQuery(const std::map<String, std::vector<String> >& query);
+ void SetArrayFormatUseBrackets(bool useBrackets = true);
void AddQueryElement(const String& name, const String& query);
void SetQueryElements(const String& name, const std::vector<String>& query);
String m_Port;
std::vector<String> m_Path;
std::map<String, std::vector<String> > m_Query;
+ bool m_ArrayFormatUseBrackets;
String m_Fragment;
bool ParseScheme(const String& scheme);
url = new Url("/");
BOOST_CHECK(url->Format(false, false) == "/");
+
+ url = new Url("https://nsclient:8443/query/check_cpu?time%5B%5D=1m&time=5m&time%5B%5D=15m");
+ url->SetArrayFormatUseBrackets(false);
+ BOOST_CHECK(url2 = new Url(url->Format(false, false)));
+
+ url = new Url("https://icinga2/query?a[]=1&a[]=2&a[]=3");
+ url->SetArrayFormatUseBrackets(true);
+ BOOST_CHECK(url2 = new Url(url->Format(false, false)));
}
BOOST_AUTO_TEST_CASE(illegal_legal_strings)