From 681d4a42803e1be45778f4036711ab49c8f1cb97 Mon Sep 17 00:00:00 2001 From: Lance Ball Date: Thu, 13 May 2021 10:53:38 -0400 Subject: [PATCH] fixup: remove stray comment/optimize regex Signed-off-by: Lance Ball --- package-lock.json | 9 --------- src/parsers.ts | 3 +-- test/integration/parser_test.ts | 1 - 3 files changed, 1 insertion(+), 12 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3707f28..72f3178 100644 --- a/package-lock.json +++ b/package-lock.json @@ -637,15 +637,6 @@ "ajv": "*" } }, - "@types/axios": { - "version": "0.14.0", - "resolved": "https://registry.npmjs.org/@types/axios/-/axios-0.14.0.tgz", - "integrity": "sha1-7CMA++fX3d1+udOr+HmZlkyvzkY=", - "dev": true, - "requires": { - "axios": "*" - } - }, "@types/cacheable-request": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/@types/cacheable-request/-/cacheable-request-6.0.1.tgz", diff --git a/src/parsers.ts b/src/parsers.ts index 2485f7c..c70d043 100644 --- a/src/parsers.ts +++ b/src/parsers.ts @@ -21,8 +21,7 @@ export class JSONParser implements Parser { // This is kind of a hack, but the payload data could be JSON in the form of a single // string, such as "some data". But without the quotes in the string, JSON.parse blows // up. We can check for this scenario and add quotes. Not sure if this is ideal. - const r = /^[[|{|"]/; - if (!r.test(payload)) { + if (!/^[[|{|"]/.test(payload)) { payload = `"${payload}"`; } } diff --git a/test/integration/parser_test.ts b/test/integration/parser_test.ts index 8c10e32..ea7f67c 100644 --- a/test/integration/parser_test.ts +++ b/test/integration/parser_test.ts @@ -59,7 +59,6 @@ describe("JSON Event Format Parser", () => { const payload = "I am a string!"; const parser = new Parser(); - // TODO: Should the parser catch the SyntaxError and re-throw a ValidationError? expect(parser.parse(payload)).to.equal("I am a string!"); });