diff --git a/src/operators.js b/src/operators.js index e233416e2..11d44fe2f 100644 --- a/src/operators.js +++ b/src/operators.js @@ -5,7 +5,7 @@ var operators = { '<': (l, r) => l < r, '>=': (l, r) => l >= r, '<=': (l, r) => l <= r, - 'contains': (l, r) => l.indexOf(r) > -1, + 'contains': (l, r) => typeof l === 'string' ? l.indexOf(r) > -1 : false, 'and': (l, r) => l && r, 'or': (l, r) => l || r }; diff --git a/test/syntax.js b/test/syntax.js index b57a85b6b..f0226a640 100644 --- a/test/syntax.js +++ b/test/syntax.js @@ -13,7 +13,8 @@ describe('expression', function() { scope = Scope.factory({ one: 1, two: 2, - x: 'XXX' + x: 'XXX', + y: undefined }); }); @@ -25,6 +26,7 @@ describe('expression', function() { it('should throw on illegal expression', function() { expect(function() { evalExp('1 contains "x"', scope); + evalExp('y contains "x"', scope); }).to.throw(); });