diff --git a/lib/areSameQuery.js b/lib/areSameQuery.js index e930c57..f32d1f8 100644 --- a/lib/areSameQuery.js +++ b/lib/areSameQuery.js @@ -21,9 +21,9 @@ function areSameQuery(queryObj1, queryObj2) // If strings don't match if (value1 !== value2) { - // Only other type allowed is Array + // Don't proceed unless both are arrays // "?var1=a&var1=b" would've been parsed to { var1: ["a","b"] } - if (Array.isArray(value1) !== Array.isArray(value2)) return false; + if (Array.isArray(value1)===false || Array.isArray(value2)===false) return false; len = value1.length; diff --git a/test/0.independent.areSameQuery.js b/test/0.independent.areSameQuery.js index ecc6dc3..6f2e413 100644 --- a/test/0.independent.areSameQuery.js +++ b/test/0.independent.areSameQuery.js @@ -54,6 +54,10 @@ describe("areSameQuery", function() query2 = {}; expect( areSameQuery(query1,query2) ).to.be.true; + query1 = { var1:"123" }; + query2 = { var1:"456" }; + expect( areSameQuery(query1,query2) ).to.be.false; + done(); }); });