From 36dc94b8f2d9636ef72512904e556afd94b86c57 Mon Sep 17 00:00:00 2001 From: Matt Visnovsky Date: Thu, 6 Jun 2024 10:04:20 -0600 Subject: [PATCH] Better type handling --- src/util.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/util.js b/src/util.js index 07cf1dc3a..967c5b425 100644 --- a/src/util.js +++ b/src/util.js @@ -399,11 +399,12 @@ function intHash(str, length = 10) { exports.intHash = intHash; async function evaluateJsonQuery(data, jsonPath, jsonPathOperator, expectedValue) { const expected = isNaN(expectedValue) ? expectedValue.toString() : parseFloat(expectedValue); - let response = isNaN(data) ? data.toString() : parseFloat(data); + let response; try { - response = JSON.parse(response); + response = JSON.parse(data); } - catch (_) { + catch (_a) { + response = typeof data === "number" || typeof data === "object" ? data : data.toString(); } let jsonQueryExpression; switch (jsonPathOperator) {