From 2d6f02f4071ce1c4f55b57265965fbf3da4d37dc Mon Sep 17 00:00:00 2001 From: Thibault Koechlin Date: Wed, 22 Oct 2025 14:54:35 +0200 Subject: [PATCH 1/4] add this useful helper in the doc --- crowdsec-docs/docs/expr/strings_helpers.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crowdsec-docs/docs/expr/strings_helpers.md b/crowdsec-docs/docs/expr/strings_helpers.md index 4b4d2c38a..e27ec01b5 100644 --- a/crowdsec-docs/docs/expr/strings_helpers.md +++ b/crowdsec-docs/docs/expr/strings_helpers.md @@ -54,6 +54,12 @@ Parses an URI into a map of string list. `QueryEscape` escapes the string so it can be safely placed inside a URL query. +### `ExtractQueryParam(query string, param string) []string` + +`ExtractQueryParam` extract the `param` parameter value from the URL query `query` and returns the list of values. + +> `any(ExtractQueryParam(uri, "id"), { # == "1" })` is any of the `id` parameter value from `uri` URI equal to `1` + ### `Sprintf(format string, a ...interface{}) string` [Official doc](https://pkg.go.dev/fmt#Sprintf) : Sprintf formats according to a format specifier and returns the resulting string. From 55ea9e194466065c8c9e2d7fd52a7af058b95dbb Mon Sep 17 00:00:00 2001 From: Thibault Koechlin Date: Wed, 22 Oct 2025 14:57:55 +0200 Subject: [PATCH 2/4] up --- crowdsec-docs/docs/expr/strings_helpers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crowdsec-docs/docs/expr/strings_helpers.md b/crowdsec-docs/docs/expr/strings_helpers.md index e27ec01b5..8e945421c 100644 --- a/crowdsec-docs/docs/expr/strings_helpers.md +++ b/crowdsec-docs/docs/expr/strings_helpers.md @@ -58,7 +58,7 @@ Parses an URI into a map of string list. `ExtractQueryParam` extract the `param` parameter value from the URL query `query` and returns the list of values. -> `any(ExtractQueryParam(uri, "id"), { # == "1" })` is any of the `id` parameter value from `uri` URI equal to `1` +> `any(ExtractQueryParam(uri, "id"), { # == "1" })` returns true fs any of the `id` parameter value from `uri` URI equals to `1` ### `Sprintf(format string, a ...interface{}) string` From 46a5aa5ab00217114520e0b2c29aab986f793173 Mon Sep 17 00:00:00 2001 From: Thibault Koechlin Date: Wed, 22 Oct 2025 15:00:01 +0200 Subject: [PATCH 3/4] up --- crowdsec-docs/docs/expr/strings_helpers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crowdsec-docs/docs/expr/strings_helpers.md b/crowdsec-docs/docs/expr/strings_helpers.md index 8e945421c..fafecf38c 100644 --- a/crowdsec-docs/docs/expr/strings_helpers.md +++ b/crowdsec-docs/docs/expr/strings_helpers.md @@ -58,7 +58,7 @@ Parses an URI into a map of string list. `ExtractQueryParam` extract the `param` parameter value from the URL query `query` and returns the list of values. -> `any(ExtractQueryParam(uri, "id"), { # == "1" })` returns true fs any of the `id` parameter value from `uri` URI equals to `1` +> `any(ExtractQueryParam("/foo?id=1&b=2", "id"), { # == "1" })` returns true as at least one of the `id` parameter value is equal to `1` ### `Sprintf(format string, a ...interface{}) string` From def39b34a176acf9873d3557895b2e573bc53be3 Mon Sep 17 00:00:00 2001 From: Thibault Koechlin Date: Wed, 22 Oct 2025 15:00:33 +0200 Subject: [PATCH 4/4] up --- crowdsec-docs/docs/expr/strings_helpers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crowdsec-docs/docs/expr/strings_helpers.md b/crowdsec-docs/docs/expr/strings_helpers.md index fafecf38c..5600925d5 100644 --- a/crowdsec-docs/docs/expr/strings_helpers.md +++ b/crowdsec-docs/docs/expr/strings_helpers.md @@ -58,7 +58,7 @@ Parses an URI into a map of string list. `ExtractQueryParam` extract the `param` parameter value from the URL query `query` and returns the list of values. -> `any(ExtractQueryParam("/foo?id=1&b=2", "id"), { # == "1" })` returns true as at least one of the `id` parameter value is equal to `1` +> `any(ExtractQueryParam("/foo?id=1&b=2", "id"), { # == "1" })` returns true if at least one of the `id` parameter value is equal to `1` ### `Sprintf(format string, a ...interface{}) string`