From 28e8d1aef3084ede72541b30e71d14a7aa66abe0 Mon Sep 17 00:00:00 2001 From: Christian Volk Date: Tue, 16 Jul 2024 12:02:46 +0200 Subject: [PATCH] added a comment to describe the regex --- .../Clusters/components/oidc-params.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/components/Clusters/components/oidc-params.ts b/src/components/Clusters/components/oidc-params.ts index 415fea2857..6cf79aa571 100644 --- a/src/components/Clusters/components/oidc-params.ts +++ b/src/components/Clusters/components/oidc-params.ts @@ -12,7 +12,22 @@ export function parseOIDCparams({ exec: commandData }: KubeconfigOIDCAuth) { let output: any = {}; commandData.args.forEach(arg => { - const regex = new RegExp('^(?[^=\\s]+)(?:=(?.*$))'); + /** + * The regular expression defined below is tailored to parse command line arguments, capturing both arguments that + * include values and those without values. The regex facilitates the extraction of both the keys and optionally + * associated values in a reliable manner. + * + * Examples of command line arguments that this regex will match: + * - With value: `--param-with-value=abc` + * - Without value: `--param-without-value` + * + * The regular expression uses named groups (`key` for the argument and `value` for its associated value, if any) + * to provide clear and convenient access to parts of the matched text. + * + * For an interactive example that demonstrates this regex pattern with various inputs and explains each part of the + * expression in detail, visit the provided link: https://regex101.com/r/3hc8qX/2 + */ + const regex = new RegExp('^(?[^=]+)(?:=(?.*$))'); const match = arg.match(regex); if (!match) {