mirror of
https://github.com/typicode/json-server.git
synced 2025-07-28 12:43:18 +08:00
Enhance query parameters parsing
This commit is contained in:
@ -9,7 +9,7 @@ _.mixin(_inflections)
|
||||
// '1' -> 1
|
||||
function toNative (value) {
|
||||
if (typeof value === 'string') {
|
||||
if (value === '' || value.trim() !== value) {
|
||||
if (value === '' || value.trim() !== value || value[0] === '0') {
|
||||
return value
|
||||
} else if (value === 'true' || value === 'false') {
|
||||
return value === 'true'
|
||||
|
@ -41,6 +41,7 @@ describe('utils', function () {
|
||||
assert.strictEqual(utils.toNative(''), '')
|
||||
assert.strictEqual(utils.toNative('\t\n'), '\t\n')
|
||||
assert.strictEqual(utils.toNative('1 '), '1 ')
|
||||
assert.strictEqual(utils.toNative('01'), '01')
|
||||
assert.strictEqual(utils.toNative(' 1'), ' 1')
|
||||
assert.strictEqual(utils.toNative('string'), 'string')
|
||||
assert.strictEqual(utils.toNative(1), 1)
|
||||
|
Reference in New Issue
Block a user