diff --git a/src/utils.js b/src/utils.js index ec86aee..a954acf 100644 --- a/src/utils.js +++ b/src/utils.js @@ -9,7 +9,9 @@ _.mixin(_inflections) // '1' -> 1 function toNative (value) { 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 } else if (value === 'true' || value === 'false') { return value === 'true' diff --git a/test/utils.js b/test/utils.js index ccfe1ec..0e7bfdd 100644 --- a/test/utils.js +++ b/test/utils.js @@ -36,6 +36,7 @@ describe('utils', function () { it('should convert string to native type', function () { // should convert assert.strictEqual(utils.toNative('1'), 1) + assert.strictEqual(utils.toNative('0'), 0) assert.strictEqual(utils.toNative('true'), true) // should not convert assert.strictEqual(utils.toNative(''), '')