mirror of
https://github.com/typicode/json-server.git
synced 2025-07-28 12:43:18 +08:00
Fix query parameters conversion
This commit is contained in:
@ -9,7 +9,9 @@ _.mixin(_inflections)
|
|||||||
// '1' -> 1
|
// '1' -> 1
|
||||||
function toNative (value) {
|
function toNative (value) {
|
||||||
if (typeof value === 'string') {
|
if (typeof value === 'string') {
|
||||||
if (value === '' || value.trim() !== value || value[0] === '0') {
|
if (value === ''
|
||||||
|
|| value.trim() !== value
|
||||||
|
|| (value.length > 1 && value[0] === '0')) {
|
||||||
return value
|
return value
|
||||||
} else if (value === 'true' || value === 'false') {
|
} else if (value === 'true' || value === 'false') {
|
||||||
return value === 'true'
|
return value === 'true'
|
||||||
|
@ -36,6 +36,7 @@ describe('utils', function () {
|
|||||||
it('should convert string to native type', function () {
|
it('should convert string to native type', function () {
|
||||||
// should convert
|
// should convert
|
||||||
assert.strictEqual(utils.toNative('1'), 1)
|
assert.strictEqual(utils.toNative('1'), 1)
|
||||||
|
assert.strictEqual(utils.toNative('0'), 0)
|
||||||
assert.strictEqual(utils.toNative('true'), true)
|
assert.strictEqual(utils.toNative('true'), true)
|
||||||
// should not convert
|
// should not convert
|
||||||
assert.strictEqual(utils.toNative(''), '')
|
assert.strictEqual(utils.toNative(''), '')
|
||||||
|
Reference in New Issue
Block a user