mirror of
https://github.com/harttle/liquidjs.git
synced 2026-10-03 09:05:14 -07:00
Illegal expression in contains
This commit is contained in:
+1
-1
@@ -5,7 +5,7 @@ var operators = {
|
|||||||
'<': (l, r) => l < r,
|
'<': (l, r) => l < r,
|
||||||
'>=': (l, r) => l >= r,
|
'>=': (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,
|
'and': (l, r) => l && r,
|
||||||
'or': (l, r) => l || r
|
'or': (l, r) => l || r
|
||||||
};
|
};
|
||||||
|
|||||||
+3
-1
@@ -13,7 +13,8 @@ describe('expression', function() {
|
|||||||
scope = Scope.factory({
|
scope = Scope.factory({
|
||||||
one: 1,
|
one: 1,
|
||||||
two: 2,
|
two: 2,
|
||||||
x: 'XXX'
|
x: 'XXX',
|
||||||
|
y: undefined
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -25,6 +26,7 @@ describe('expression', function() {
|
|||||||
it('should throw on illegal expression', function() {
|
it('should throw on illegal expression', function() {
|
||||||
expect(function() {
|
expect(function() {
|
||||||
evalExp('1 contains "x"', scope);
|
evalExp('1 contains "x"', scope);
|
||||||
|
evalExp('y contains "x"', scope);
|
||||||
}).to.throw();
|
}).to.throw();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user