From 0c19ff0b5362c49d0cc81156238ddb67184d41f3 Mon Sep 17 00:00:00 2001 From: Raphael Pinto Date: Sat, 16 Sep 2017 16:19:11 -0300 Subject: [PATCH 1/2] Add support to multi-valued fields in query string --- index.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/index.js b/index.js index 0776514..70e2b6c 100644 --- a/index.js +++ b/index.js @@ -6,6 +6,11 @@ function getQuery (queryParams) { var arr = Object.keys(queryParams).map(function (k) { + if(Array.isArray(queryParams[k])){ + return queryParams[k].map((v) => { + return [k+'[]', encodeURIComponent(v)].join('=') + }).join("&") + } return [k, encodeURIComponent(queryParams[k])].join('=') }) return '?' + arr.join('&') From 81b382df31efb6f80df6253a1bca257bf0205f62 Mon Sep 17 00:00:00 2001 From: Raphael Pinto Date: Sun, 17 Sep 2017 11:24:51 -0300 Subject: [PATCH 2/2] Remove Arrow function --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 70e2b6c..ae2c90a 100644 --- a/index.js +++ b/index.js @@ -7,7 +7,7 @@ function getQuery (queryParams) { var arr = Object.keys(queryParams).map(function (k) { if(Array.isArray(queryParams[k])){ - return queryParams[k].map((v) => { + return queryParams[k].map(function (v) { return [k+'[]', encodeURIComponent(v)].join('=') }).join("&") }