From b761165c25665f627ca4c087fe81f01b84d2e2d2 Mon Sep 17 00:00:00 2001 From: calidion Date: Tue, 15 Mar 2016 17:48:40 +0800 Subject: [PATCH] fixed a bug --- lib/index.js | 2 +- package.json | 2 +- test/index.js | 5 ++++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/index.js b/lib/index.js index d51a7f5..bac1995 100644 --- a/lib/index.js +++ b/lib/index.js @@ -22,7 +22,7 @@ module.exports = { params = params || {}; var keys = []; for (var k in params) { - if (typeof params[k] === 'string') { + if (['string', 'number'].indexOf(typeof params[k]) !== -1) { keys.push(encodeURIComponent(k) + '=' + encodeURIComponent(params[k])); } } diff --git a/package.json b/package.json index 4df4025..e57083b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "node-weixin-util", - "version": "0.3.0", + "version": "0.3.1", "description": "", "homepage": "", "author": { diff --git a/test/index.js b/test/index.js index 4c0bb37..f88b9b0 100644 --- a/test/index.js +++ b/test/index.js @@ -15,11 +15,14 @@ describe('node-weixin-util node module', function () { var params = { a: '1', c: '2', + d: 3, + e: 3.1, 'd-c': 'aaa' }; var url = nodeWeixinUtil.toParam(params); - assert.equal(true, url === 'a=1&c=2&d-c=aaa'); + console.log(url); + assert.equal(true, url === 'a=1&c=2&d=3&e=3.1&d-c=aaa'); params = { a: '1', c: '2',