Skip to content

Commit

Permalink
added a comment to describe the regex
Browse files Browse the repository at this point in the history
  • Loading branch information
v0lkc committed Jul 16, 2024
1 parent 085b556 commit 28e8d1a
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/components/Clusters/components/oidc-params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,22 @@ export function parseOIDCparams({ exec: commandData }: KubeconfigOIDCAuth) {
let output: any = {};

commandData.args.forEach(arg => {
const regex = new RegExp('^(?<key>[^=\\s]+)(?:=(?<value>.*$))');
/**
* 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('^(?<key>[^=]+)(?:=(?<value>.*$))');
const match = arg.match(regex);

if (!match) {
Expand Down

0 comments on commit 28e8d1a

Please sign in to comment.