matches snapshot with empty matcher 1`] = `
+"
+
+ 0
+
+"
+`;
diff --git a/ui/src/Stores/AlertStore.js b/ui/src/Stores/AlertStore.js
index 3648e3afd..7bd470fd6 100644
--- a/ui/src/Stores/AlertStore.js
+++ b/ui/src/Stores/AlertStore.js
@@ -6,16 +6,22 @@ import equal from "fast-deep-equal";
import qs from "qs";
+const QueryStringEncodeOptions = {
+ encodeValuesOnly: true, // don't encode q[]
+ indices: false // go-gin doesn't support parsing q[0]=foo&q[1]=bar
+};
+
+function FormatAlertsQ(filters) {
+ return qs.stringify({ q: filters }, QueryStringEncodeOptions);
+}
+
// generate URL for the UI with a set of filters
function FormatAPIFilterQuery(filters) {
return qs.stringify(
Object.assign(DecodeLocationSearch(window.location.search).params, {
q: filters
}),
- {
- encodeValuesOnly: true, // don't encode q[]
- indices: false // go-gin doesn't support parsing q[0]=foo&q[1]=bar
- }
+ QueryStringEncodeOptions
);
}
@@ -336,6 +342,7 @@ export {
AlertStoreStatuses,
FormatBackendURI,
FormatAPIFilterQuery,
+ FormatAlertsQ,
DecodeLocationSearch,
UpdateLocationSearch,
NewUnappliedFilter
diff --git a/ui/src/Stores/AlertStore.test.js b/ui/src/Stores/AlertStore.test.js
index 90e3473a2..a9df5f260 100644
--- a/ui/src/Stores/AlertStore.test.js
+++ b/ui/src/Stores/AlertStore.test.js
@@ -4,6 +4,7 @@ import {
AlertStore,
AlertStoreStatuses,
FormatBackendURI,
+ FormatAlertsQ,
DecodeLocationSearch,
UpdateLocationSearch,
NewUnappliedFilter
@@ -146,6 +147,12 @@ describe("FormatBackendURI", () => {
});
});
+describe("FormatAlertsQ", () => {
+ it("encodes multiple values without indices", () => {
+ expect(FormatAlertsQ(["a", "b"])).toBe("q=a&q=b");
+ });
+});
+
describe("DecodeLocationSearch", () => {
const defaultParams = {
defaultsUsed: true,