From 4830fd7e02d24ff99674e5ea871c6cacb9ef85b1 Mon Sep 17 00:00:00 2001 From: typicode Date: Fri, 15 May 2015 02:34:00 +0200 Subject: [PATCH] Enhance query parameters parsing --- src/utils.js | 2 +- test/utils.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/utils.js b/src/utils.js index 807eb42..ec86aee 100644 --- a/src/utils.js +++ b/src/utils.js @@ -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' diff --git a/test/utils.js b/test/utils.js index 111dc93..ccfe1ec 100644 --- a/test/utils.js +++ b/test/utils.js @@ -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)