Rename server => modules
This commit is contained in:
16
modules/utils/createSearch.js
Normal file
16
modules/utils/createSearch.js
Normal file
@ -0,0 +1,16 @@
|
||||
function createSearch(query) {
|
||||
const keys = Object.keys(query).sort();
|
||||
const params = keys.reduce(
|
||||
(memo, key) =>
|
||||
memo.concat(
|
||||
query[key] === ""
|
||||
? key // Omit the trailing "=" from key=
|
||||
: `${key}=${encodeURIComponent(query[key])}`
|
||||
),
|
||||
[]
|
||||
);
|
||||
|
||||
return params.length ? `?${params.join("&")}` : "";
|
||||
}
|
||||
|
||||
module.exports = createSearch;
|
Reference in New Issue
Block a user