diff --git a/src/path/expression.ts b/src/path/expression.ts index d214fcb..31cdbf0 100644 --- a/src/path/expression.ts +++ b/src/path/expression.ts @@ -132,11 +132,19 @@ export class InfixExpression extends FilterExpression { public evaluate(context: FilterContext): boolean { let left = this.left.evaluate(context); - if (!this.logical && left instanceof JSONPathNodeList && left.nodes.length === 1) + if ( + !this.logical && + left instanceof JSONPathNodeList && + left.nodes.length === 1 + ) left = left.nodes[0].value; let right = this.right.evaluate(context); - if (!this.logical && right instanceof JSONPathNodeList && right.nodes.length === 1) + if ( + !this.logical && + right instanceof JSONPathNodeList && + right.nodes.length === 1 + ) right = right.nodes[0].value; if (this.operator === "&&") { diff --git a/tests/path/query.test.ts b/tests/path/query.test.ts index 8c8e62d..56aec62 100644 --- a/tests/path/query.test.ts +++ b/tests/path/query.test.ts @@ -1,10 +1,9 @@ import { query } from "../../src/path"; describe("JSONPath query", () => { - test("logical expression, existence tests", () => { - const path = "$[?@.a && @.b]"; - const data = [{"a": false, "b": false}]; - expect(query(path, data).values()).toStrictEqual([{"a": false, "b": false}]); - }); - } -); \ No newline at end of file + test("logical expression, existence tests", () => { + const path = "$[?@.a && @.b]"; + const data = [{ a: false, b: false }]; + expect(query(path, data).values()).toStrictEqual([{ a: false, b: false }]); + }); +});