Skip to content

Commit 179b441

Browse files
committed
Merge branch 'hotfix/2.1.7'
2 parents 7e61b3d + 52465bd commit 179b441

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

lib/mapper/ordination.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function ordination(query, options) {
1616

1717
function processQuery(query) {
1818
const result = {}
19-
query = query.replace(/([^\w\s,-])|(\s{1,})/gi, '')
19+
query = query.replace(/([^\w\s,.-])|(\s{1,})/gi, '')
2020
query.split(',').forEach(function (elem) {
2121
elem = elem.trim()
2222
if (elem[0] === '-') result[elem.substr(1)] = -1

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "query-strings-parser",
3-
"version": "2.1.6",
3+
"version": "2.1.7",
44
"description": "Middleware to transform query strings in a format that is recognized by the MongoDB, MySQL and other databases...",
55
"license": "MIT",
66
"main": "index.js",
@@ -44,7 +44,7 @@
4444
"devDependencies": {
4545
"chai": "^4.2.0",
4646
"express": "^4.17.1",
47-
"mocha": "^8.1.1",
47+
"mocha": "^8.1.3",
4848
"nyc": "^15.1.0",
4949
"supertest": "^4.0.2"
5050
}

test/unit/ordination.spec.js

+8
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ describe('QueryString: Ordination', function () {
1010
})
1111
})
1212

13+
context('when ordination query is a second-level string', function () {
14+
it('should return a JSON with order params', function (done) {
15+
const result = ordination.sort({sort: '-user.age'}, default_options)
16+
expect(result['user.age']).to.eql(-1)
17+
done()
18+
})
19+
})
20+
1321
context('when ordination query is an array of strings', function () {
1422
it('should return a JSON with order params', function (done) {
1523
verify(ordination.sort({sort: ['-name,age', 'created_at']}, default_options))

0 commit comments

Comments
 (0)