Skip to content

Commit

Permalink
♻️ Cleaning up some unwanted request params
Browse files Browse the repository at this point in the history
  • Loading branch information
jolzee committed Feb 22, 2020
1 parent 2f4463c commit 09cec58
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ export const sleep = (ms = 0) => {
};

export const queryParamStringAsObject = fullQueryString => {
const queryString = {};
let queryString = {};
const query = fullQueryString;
const vars = query.split("&");
for (let i = 0; i < vars.length; i++) {
Expand All @@ -727,6 +727,10 @@ export const queryParamStringAsObject = fullQueryString => {
queryString[pair[0]].push(decodeURIComponent(pair[1]));
}
}
queryString = Object.entries(queryString).reduce(
(a, [k, v]) => (k === "" || v == null || v === "undefined" ? a : { ...a, [k]: v }),
{}
); // Filter null and undefined values
return queryString;
};

Expand Down

0 comments on commit 09cec58

Please sign in to comment.