Skip to content
This repository has been archived by the owner on Apr 24, 2024. It is now read-only.

Commit

Permalink
Flow config parser: Regex simplification
Browse files Browse the repository at this point in the history
Trying to simplify regex as suggested:
https://github.com/adeira/universe/security/code-scanning/4

Looks like explicit whitespace matches are not needed, let's see if the code scan will be happy.

adeira-source-id: 3c27214131da424b9ffd6d89675c96b51f38ae7b
  • Loading branch information
michalsanger authored and adeira-github-bot committed May 20, 2021
1 parent f5707f3 commit 610c723
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@adeira/flow-config-parser",
"description": "Permissive Flow config parser.",
"homepage": "https://github.com/adeira/universe/tree/master/src/flow-config-parser",
"version": "0.2.0",
"version": "0.3.0",
"private": false,
"license": "MIT",
"main": "./src/index.js",
Expand Down
4 changes: 1 addition & 3 deletions src/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ export default function parse(input: string): ParsedConfig {
parsedConfig[currentSection] = line;
} else {
// process it as a key/value (while ignoring rollout annotations since we do not merge them properly, yet)
const keyValueMatch = line.match(
/^(?:(?<rollout>\(.+\))\s?)?(?<rawKey>.+)\s*?=\s*?(?<rawValue>.+)$/,
);
const keyValueMatch = line.match(/^(?:(?<rollout>\(.+\)))?(?<rawKey>.+)=(?<rawValue>.+)$/);
if (keyValueMatch) {
const rawKey = keyValueMatch.groups?.rawKey;
const rawValue = keyValueMatch.groups?.rawValue;
Expand Down

0 comments on commit 610c723

Please sign in to comment.