Skip to content

Commit 5c08d81

Browse files
committed
[HOTFIX 2.1.7] Bug fixes
Adding second-level keys for ordination.
1 parent 7e61b3d commit 5c08d81

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lib/mapper/ordination.js

Lines changed: 1 addition & 1 deletion
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

test/unit/ordination.spec.js

Lines changed: 8 additions & 0 deletions
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)