From af9d9132d2b49408d380b5ee87d49f6343dcd9db Mon Sep 17 00:00:00 2001 From: Brett Sun Date: Tue, 5 Jan 2016 14:13:46 +0100 Subject: [PATCH] Use query-string instead of qs Saves bytes, as done by rackt/history: https://github.com/rackt/history/issues/121 --- js/utils/url_utils.js | 11 +++++------ package.json | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/js/utils/url_utils.js b/js/utils/url_utils.js index 86c8dfc5..94584026 100644 --- a/js/utils/url_utils.js +++ b/js/utils/url_utils.js @@ -2,7 +2,7 @@ import camelCase from 'camelcase'; import decamelize from 'decamelize'; -import qs from 'qs'; +import queryString from 'query-string'; import { sanitize } from './general_utils'; @@ -36,8 +36,7 @@ export function argsToQueryParams(obj) { queryParamObj[decamelize(key)] = sanitizedObj[key]; }); - // Use bracket arrayFormat as history.js and react-router use it - return '?' + qs.stringify(queryParamObj, { arrayFormat: 'brackets' }); + return '?' + queryString.stringify(queryParamObj); } /** @@ -56,13 +55,13 @@ export function getCurrentQueryParams() { * @return {object} Query params dictionary */ export function queryParamsToArgs(queryParamString) { - const qsQueryParamObj = qs.parse(queryParamString); + const queryParamObj = queryString.parse(queryParamString); const camelCaseParamObj = {}; Object - .keys(qsQueryParamObj) + .keys(queryParamObj) .forEach((key) => { - camelCaseParamObj[camelCase(key)] = qsQueryParamObj[key]; + camelCaseParamObj[camelCase(key)] = queryParamObj[key]; }); return camelCaseParamObj; diff --git a/package.json b/package.json index ec4d505e..a874ea2c 100644 --- a/package.json +++ b/package.json @@ -75,7 +75,7 @@ "object-assign": "^2.0.0", "opn": "^3.0.2", "q": "^1.4.1", - "qs": "^4.0.0", + "query-string": "^3.0.0", "raven-js": "^1.1.19", "react": "0.13.2", "react-bootstrap": "0.25.1",