mirror of
https://github.com/typicode/json-server.git
synced 2025-08-03 04:12:22 +08:00
make _like operator case insensitive
This commit is contained in:
@ -1,5 +1,9 @@
|
||||
# Change Log
|
||||
|
||||
## [0.8.13][2016-05-12]
|
||||
|
||||
* Make `_like` operator case insensitive
|
||||
|
||||
## [0.8.12][2016-05-08]
|
||||
|
||||
* Minor bug fix
|
||||
@ -11,8 +15,6 @@
|
||||
|
||||
## [0.8.10][2016-04-18]
|
||||
|
||||
### Added
|
||||
|
||||
* CLI option `-ng/--no-gzip` to disable `gzip` compression
|
||||
|
||||
## [0.8.9][2016-03-17]
|
||||
|
@ -118,7 +118,7 @@ Add `_ne` to exclude a value
|
||||
GET /posts?id_ne=1
|
||||
```
|
||||
|
||||
Add `_like` to filter using RegExp
|
||||
Add `_like` to filter (RegExp supported)
|
||||
|
||||
```
|
||||
GET /posts?title_like=server
|
||||
|
@ -125,7 +125,7 @@ module.exports = function (db, name) {
|
||||
} else if (isDifferent) {
|
||||
return value !== elementValue
|
||||
} else if (isLike) {
|
||||
return new RegExp(value).test(elementValue)
|
||||
return new RegExp(value, 'i').test(elementValue)
|
||||
} else {
|
||||
return _.matchesProperty(key, value)(element)
|
||||
}
|
||||
|
@ -259,9 +259,9 @@ describe('Server', function () {
|
||||
})
|
||||
|
||||
describe('GET /:resource?attr_like=', function () {
|
||||
it('should respond with an array that matches the like operator', function (done) {
|
||||
it('should respond with an array that matches the like operator (case insensitive)', function (done) {
|
||||
request(server)
|
||||
.get('/tags?body_like=hoto')
|
||||
.get('/tags?body_like=photo')
|
||||
.expect('Content-Type', /json/)
|
||||
.expect([
|
||||
db.tags[1],
|
||||
|
Reference in New Issue
Block a user