Skip to content

Commit

Permalink
Use query-string instead of qs
Browse files Browse the repository at this point in the history
Saves bytes, as done by rackt/history:
remix-run/history#121
  • Loading branch information
Brett Sun committed Jan 5, 2016
1 parent c3f0586 commit af9d913
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
11 changes: 5 additions & 6 deletions js/utils/url_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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);
}

/**
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit af9d913

Please sign in to comment.