From 610c72364d2e96dc7cfb587de031f327955bd2be Mon Sep 17 00:00:00 2001 From: Michal Sanger Date: Wed, 12 May 2021 11:14:29 +0200 Subject: [PATCH] Flow config parser: Regex simplification 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 --- package.json | 2 +- src/parse.js | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 984d776..2cbb989 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/parse.js b/src/parse.js index b9c735a..d4af196 100644 --- a/src/parse.js +++ b/src/parse.js @@ -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( - /^(?:(?\(.+\))\s?)?(?.+)\s*?=\s*?(?.+)$/, - ); + const keyValueMatch = line.match(/^(?:(?\(.+\)))?(?.+)=(?.+)$/); if (keyValueMatch) { const rawKey = keyValueMatch.groups?.rawKey; const rawValue = keyValueMatch.groups?.rawValue;