diff --git a/package.json b/package.json index 35d795f..1640426 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rsql-mongodb", - "version": "2.0.0", + "version": "2.0.1", "description": "Converting RSQL queries to MongoDB queries", "main": "rsql-mongodb.js", "typings": "rsql-mongodb.ts", diff --git a/test.js b/test.js index a908669..2f07c3d 100644 --- a/test.js +++ b/test.js @@ -55,6 +55,7 @@ describe('rsql-mongodb', function () { }); it("Test operator Like ('=regex=')", function () { expect(rsqlMongoDB('lastName=regex=do*')).to.deep.include({ "lastName": { $regex: "do*", $options: "" } }); + expect(rsqlMongoDB('lastName=regex=.*oe')).to.deep.include({ "lastName": { $regex: ".*oe", $options: "" } }); expect(rsqlMongoDB('lastName=regex=do*=i')).to.deep.include({ "lastName": { $regex: "do*", $options: "i" } }); expect(rsqlMongoDB('lastName=regex=do*=mxs')).to.deep.include({ "lastName": { $regex: "do*", $options: "mxs" } }); expect(rsqlMongoDB('lastName=regex="do=*"=mxs')).to.deep.include({ "lastName": { $regex: "do=*", $options: "mxs" } }); @@ -83,6 +84,7 @@ describe('rsql-mongodb', function () { it("Test errors", function () { expect(function () { rsqlMongoDB('azerty') }).to.throw('Wrong RSQL query. No operator found.'); expect(function () { rsqlMongoDB('lastName=~do*') }).to.throw('Wrong RSQL query. No operator found.'); + expect(function () { rsqlMongoDB('lastName=regex=*oe') }).to.throw('Invalid regular expression'); expect(function () { rsqlMongoDB("name=='SELECT (CHaR(75)||CHaR(76)||CHaR(77))'") }).to.throw('Wrong RSQL query. No operator found.'); expect(function () { rsqlMongoDB('firstName=={ $where: [ { lastName : "doe" } ] }') }).to.throw('Injection detected.'); expect(function () { rsqlMongoDB('birthday==1959-21-12') }).to.throw('Invalid Date.');