From 1aa80e894b224716abc73c91f96bfc20645f8ea9 Mon Sep 17 00:00:00 2001 From: Aleksei Androsov Date: Thu, 17 Apr 2014 21:18:57 +0400 Subject: [PATCH] Fix jpath in case of null property --- jpath.js | 2 +- test/spec/jpath.js | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/jpath.js b/jpath.js index c0d772f..7aa1f08 100644 --- a/jpath.js +++ b/jpath.js @@ -413,7 +413,7 @@ var executors = { return json; } - if (typeof json === 'object') { + if (typeof json === 'object' && json !== null) { // в массиве нужно выполнить шаг для каждого элемента if (isArray(json)) { var arr = []; diff --git a/test/spec/jpath.js b/test/spec/jpath.js index 4b4bfdc..d1ecab9 100644 --- a/test/spec/jpath.js +++ b/test/spec/jpath.js @@ -240,6 +240,10 @@ describe('jpath', function() { expect(jpath(json, '.c[.nu].d.e')).to.eql([]); }); + it('.c.nu.d.e -', function() { + expect(jpath(json, '.c.nu.d.e')).to.eql([]); + }); + it('.c[.ea].d.e -', function() { expect(jpath(json, '.c[.nu].d.e')).to.eql([]); });