Move middleware utils into server/utils

This commit is contained in:
Michael Jackson
2018-05-21 13:26:00 -07:00
parent 269b756aeb
commit c792515d01
14 changed files with 59 additions and 40 deletions

View File

@ -0,0 +1,17 @@
function createSearch(query) {
const params = [];
Object.keys(query).forEach(param => {
if (query[param] === "") {
params.push(param); // Omit the trailing "=" from param=
} else {
params.push(`${param}=${encodeURIComponent(query[param])}`);
}
});
const search = params.join("&");
return search ? `?${search}` : "";
}
module.exports = createSearch;