From b916de78a05d9f6841092caa4ba705c9c9363dd3 Mon Sep 17 00:00:00 2001 From: Nicolas Pelletier Date: Mon, 20 Mar 2017 13:35:12 +0100 Subject: [PATCH 1/2] Fix comparison with single "=" by throwing a better error message. --- jmespath.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/jmespath.js b/jmespath.js index f59e8e4..d7a8638 100644 --- a/jmespath.js +++ b/jmespath.js @@ -402,6 +402,10 @@ if (stream[this._current] === "=") { this._current++; return {type: TOK_EQ, value: "==", start: start}; + } else { + var error = new Error("Unexpected token: do you mean `==' operator ?"); + error.name = "ParserError"; + throw error; } } }, From 2c1ed0b0666b2ce1e8f2813adde43f0853aca978 Mon Sep 17 00:00:00 2001 From: Nicolas Pelletier Date: Mon, 20 Mar 2017 15:14:18 +0100 Subject: [PATCH 2/2] Fix on requesting data stored in Native named objects (e.g. Error, Date, Function, ...) --- jmespath.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/jmespath.js b/jmespath.js index d7a8638..b26874d 100644 --- a/jmespath.js +++ b/jmespath.js @@ -17,6 +17,13 @@ } } + function isTraversable(obj) { + if (obj == null) return false; + var type = typeof obj; + if (type != 'function' && type != 'object') return false; + return true; + } + function strictDeepEqual(first, second) { // Check the scalar case first. if (first === second) { @@ -872,7 +879,7 @@ case "Field": if (value === null ) { return null; - } else if (isObject(value)) { + } else if (isTraversable(value)) { field = value[node.name]; if (field === undefined) { return null;