add query param even when value is missing (#1370)

This commit is contained in:
Adarsh Lilha 2024-01-29 23:34:35 +05:30 committed by GitHub
parent 467e63d6fa
commit 0dd8154d8b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -33,8 +33,13 @@ export const stringifyQueryParams = (params) => {
let queryString = [];
each(params, (p) => {
if (!isEmpty(trim(p.name)) && !isEmpty(trim(p.value))) {
queryString.push(`${p.name}=${p.value}`);
const hasEmptyName = isEmpty(trim(p.name));
const hasEmptyVal = isEmpty(trim(p.value));
// query param name must be present
if (!hasEmptyName) {
// if query param value is missing, push only <param-name>, else push <param-name: param-value>
queryString.push(hasEmptyVal ? p.name : `${p.name}=${p.value}`);
}
});