Skip to content

Commit 47a340e

Browse files
committed
Merge branch 'hotfix/2.1.6'
2 parents 4589201 + 3421639 commit 47a340e

File tree

4 files changed

+16
-7
lines changed

4 files changed

+16
-7
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ For informations and details about the supported query strings, access the [wiki
250250
[npm-url]: https://npmjs.org/package/query-strings-parser
251251
[downloads-image]: https://img.shields.io/npm/dt/query-strings-parser.svg?logo=npm
252252
[travis-image]: https://img.shields.io/travis/nutes-uepb/query-strings-parser.svg?logo=travis
253-
[travis-url]: https://travis-ci.org/nutes-uepb/query-strings-parser
253+
[travis-url]: https://travis-ci.com/nutes-uepb/query-strings-parser
254254
[coverage-image]: https://coveralls.io/repos/github/nutes-uepb/query-strings-parser/badge.svg
255255
[coverage-url]: https://coveralls.io/github/nutes-uepb/query-strings-parser?branch=master
256256
[known-vulnerabilities-image]: https://snyk.io/test/github/nutes-uepb/query-strings-parser/badge.svg?targetFile=package.json

lib/mapper/filters.js

+10
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,23 @@ function splitByCommas(key, value) {
8080

8181
function buildRegEx(value) {
8282
value = value.replace(/(^\*{2,})|\*{2,}$/gi, '*')
83+
value = addAccentsRegex(value)
8384
const result = {'$options': 'i'}
8485
if (!value.startsWith('*') && value.endsWith('*')) result.$regex = '^'.concat(value.replace(/([*])/gi, ''))
8586
else if (value.startsWith('*') && !value.endsWith('*')) result.$regex = value.replace(/([*])/gi, '').concat('$')
8687
else result.$regex = value.replace(/([*])/gi, '')
88+
8789
return result
8890
}
8991

92+
function addAccentsRegex(string = '') {
93+
return string.replace(/a/g, '[a,á,à,ä,â,ã]')
94+
.replace(/e/g, '[e,é,ë,ê]')
95+
.replace(/i/g, '[i,í,ï]')
96+
.replace(/o/g, '[o,ó,ö,ò,ô]')
97+
.replace(/u/g, '[u,ü,ú,ù]')
98+
}
99+
90100
function parseDate(query, options) {
91101
const result = []
92102
if (query.start_at === 'today') query.start_at = normalizeDate(dateToString(new Date()), true)

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.5",
3+
"version": "2.1.6",
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": "^7.2.0",
47+
"mocha": "^8.1.1",
4848
"nyc": "^15.1.0",
4949
"supertest": "^4.0.2"
5050
}

test/integration/index.default.config.spec.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ describe('queryFilter()', function () {
8888
return request(app)
8989
.get(query)
9090
.then(res => {
91-
console.table(res.body)
9291
validate(res.body, options)
9392
})
9493
})
@@ -133,13 +132,13 @@ describe('queryFilter()', function () {
133132
const expect_filters = {
134133
'$and': [
135134
{
136-
name: {'$options': 'i', '$regex': '^lucas'}
135+
name: { '$options': 'i', '$regex': '^l[u,ü,ú,ù]c[a,á,à,ä,â,ã]s' }
137136
},
138137
{
139-
name: {'$options': 'i', '$regex': 'douglas$'}
138+
name: { '$options': 'i', '$regex': 'd[o,ó,ö,ò,ô][u,ü,ú,ù]gl[a,á,à,ä,â,ã]s$' }
140139
},
141140
{
142-
name: {'$options': 'i', '$regex': 'jorge'}
141+
name: { '$options': 'i', '$regex': 'j[o,ó,ö,ò,ô]rg[e,é,ë,ê]' }
143142
}],
144143
'school.name': 'UEPB',
145144
'timestamp': '2018-12-05T00:00:00',

0 commit comments

Comments
 (0)