diff --git a/gun.js b/gun.js index aa51c65f..922e3a18 100644 --- a/gun.js +++ b/gun.js @@ -476,7 +476,7 @@ var gun = this.chain(); cb = cb || function(){}; opt = opt || {}; - if((path !== null && !path) || path === null || !Gun.text.is(path = path.join? path.join('.') : path + '')){ return } + if(!Gun.text.is(path = Gun.text.is(path)? path || null : Gun.num.is(path)? (path + '') : Gun.list.is(path)? path.join('.') : path)){ return cb.call(gun, {err: Gun.log("Invalid path '" + path + "'!")}), gun } if(!gun.back._.at){ return cb.call(gun, {err: Gun.log("No context!")}), gun } gun.back.on(function($, node){ @@ -764,7 +764,7 @@ Util.bi.is = function(b){ return (b instanceof Boolean || typeof b == 'boolean')? true : false } Util.num = {}; Util.num.is = function(n){ - return ((n===0)? true : (!isNaN(n) && !Util.bi.is(n) && !Util.list.is(n) && !Util.text.is(n))? true : false ); + return !Util.list.is(n) && (Infinity === n || n - parseFloat(n) + 1 >= 0); // jquery doesn't check for Infinity. } Util.text = {}; Util.text.is = function(t){ return typeof t == 'string'? true : false } diff --git a/test/common.js b/test/common.js index 1a31ccd6..468524f5 100644 --- a/test/common.js +++ b/test/common.js @@ -9,7 +9,7 @@ describe('Gun', function(){ var t = {}; describe('Utility', function(){ - + var u; /* // causes logger to no longer log. it('verbose console.log debugging', function(done) { @@ -38,6 +38,8 @@ describe('Gun', function(){ it('binary', function(){ expect(Gun.bi.is(false)).to.be(true); expect(Gun.bi.is(true)).to.be(true); + expect(Gun.bi.is(u)).to.be(false); + expect(Gun.bi.is(null)).to.be(false); expect(Gun.bi.is('')).to.be(false); expect(Gun.bi.is('a')).to.be(false); expect(Gun.bi.is(0)).to.be(false); @@ -52,6 +54,8 @@ describe('Gun', function(){ expect(Gun.num.is(0)).to.be(true); expect(Gun.num.is(1)).to.be(true); expect(Gun.num.is(Infinity)).to.be(true); + expect(Gun.num.is(u)).to.be(false); + expect(Gun.num.is(null)).to.be(false); expect(Gun.num.is(NaN)).to.be(false); expect(Gun.num.is('')).to.be(false); expect(Gun.num.is('a')).to.be(false); @@ -66,6 +70,8 @@ describe('Gun', function(){ it('text',function(){ expect(Gun.text.is('')).to.be(true); expect(Gun.text.is('a')).to.be(true); + expect(Gun.text.is(u)).to.be(false); + expect(Gun.text.is(null)).to.be(false); expect(Gun.text.is(false)).to.be(false); expect(Gun.text.is(true)).to.be(false); expect(Gun.text.is(0)).to.be(false); @@ -79,6 +85,8 @@ describe('Gun', function(){ it('list',function(){ expect(Gun.list.is([])).to.be(true); expect(Gun.list.is([1])).to.be(true); + expect(Gun.list.is(u)).to.be(false); + expect(Gun.list.is(null)).to.be(false); expect(Gun.list.is(0)).to.be(false); expect(Gun.list.is(1)).to.be(false); expect(Gun.list.is('')).to.be(false); @@ -92,6 +100,8 @@ describe('Gun', function(){ it('obj',function(){ expect(Gun.obj.is({})).to.be(true); expect(Gun.obj.is({a:1})).to.be(true); + expect(Gun.obj.is(u)).to.be(false); + expect(Gun.obj.is(null)).to.be(false); expect(Gun.obj.is(0)).to.be(false); expect(Gun.obj.is(1)).to.be(false); expect(Gun.obj.is('')).to.be(false); @@ -104,6 +114,8 @@ describe('Gun', function(){ }); it('fns',function(){ expect(Gun.fns.is(function(){})).to.be(true); + expect(Gun.fns.is(u)).to.be(false); + expect(Gun.fns.is(null)).to.be(false); expect(Gun.fns.is('')).to.be(false); expect(Gun.fns.is('a')).to.be(false); expect(Gun.fns.is(0)).to.be(false);