Skip to content

Commit

Permalink
Refactor url encode method slightly
Browse files Browse the repository at this point in the history
  • Loading branch information
DM-Francis committed Feb 13, 2021
1 parent bbbaaee commit 1173eaf
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions codegens/http/lib/util.js
Expand Up @@ -127,17 +127,13 @@ function convertPropertyListToString (propertyList, joinUsing, includeDisabled =
* @returns {String} Stringified and Url encoded property List
*/
function convertPropListToStringUrlEncoded (propertyList, joinUsing, includeDisabled = false, trimRequestBody = false) {
let properties = getMembersOfPropertyList(propertyList, includeDisabled);
const keyvalues = [];
const properties = getMembersOfPropertyList(propertyList, includeDisabled),
keyvalues = [];

properties.forEach((property) => {
let keyvalue;
if (trimRequestBody) {
keyvalue = `${encodeURIComponent(property.key.trim())}=${encodeURIComponent(property.value.trim())}`;
}
else {
keyvalue = `${encodeURIComponent(property.key)}=${encodeURIComponent(property.value)}`;
}
const key = trimRequestBody ? property.key.trim() : property.key,
value = trimRequestBody ? property.value.trim() : property.value,
keyvalue = `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;

keyvalues.push(keyvalue);
});
Expand Down

0 comments on commit 1173eaf

Please sign in to comment.