From 81ab756cd6399a3b6cc6d1b317724fa7f05b16df Mon Sep 17 00:00:00 2001 From: Artem Danilov <598840+thommeo@users.noreply.github.com> Date: Tue, 22 Dec 2020 16:43:22 +0300 Subject: [PATCH 1/2] fix(parser): fix bug with parsing equals character (=) in the value of an option Parser changed not to discard the part of the option value that comes after the equals character in the string. --- src/parser/__tests__/parser.spec.ts | 16 ++++++++++++++++ src/parser/index.ts | 4 +++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/parser/__tests__/parser.spec.ts b/src/parser/__tests__/parser.spec.ts index 5e4c755..eba76de 100644 --- a/src/parser/__tests__/parser.spec.ts +++ b/src/parser/__tests__/parser.spec.ts @@ -156,6 +156,22 @@ describe("Parser", () => { }) }) + it("should parse option with value having \"=\" (equals) character, using equals notation", () => { + const line = "--opt=field=val" + const result = parseLine(line) + expect(result.options).toEqual({ + opt: 'field=val' + }) + }) + + it("should parse option with value having \"=\" (equals) character, using space notation", () => { + const line = "--opt field=val" + const result = parseLine(line) + expect(result.options).toEqual({ + opt: 'field=val' + }) + }) + describe("should handle aliases", () => { test("with simple options", () => { const line = "--my-opt true --int 23456 --float=3.14159265 --on=on -t=my-type" diff --git a/src/parser/index.ts b/src/parser/index.ts index e1ae9cf..e5a64f6 100644 --- a/src/parser/index.ts +++ b/src/parser/index.ts @@ -287,7 +287,9 @@ class OptionParser { return false } - const [name, rawval] = tree.current.split("=", 2) + const parts = tree.current.split("=") + const name = parts.shift() || "" + const rawval = parts.length ? parts.join("=") : undefined const concatOpts = isConcatenatedOpt(name) if (concatOpts) { From 33cf7e49c3fae3932e27b5e6b0a7aca4b407dcbc Mon Sep 17 00:00:00 2001 From: Artem Danilov <598840+thommeo@users.noreply.github.com> Date: Mon, 28 Jun 2021 22:22:56 +0300 Subject: [PATCH 2/2] retrigger checks