Skip to content

Commit 1173eaf

Browse files
committed
Refactor url encode method slightly
1 parent bbbaaee commit 1173eaf

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

codegens/http/lib/util.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -127,17 +127,13 @@ function convertPropertyListToString (propertyList, joinUsing, includeDisabled =
127127
* @returns {String} Stringified and Url encoded property List
128128
*/
129129
function convertPropListToStringUrlEncoded (propertyList, joinUsing, includeDisabled = false, trimRequestBody = false) {
130-
let properties = getMembersOfPropertyList(propertyList, includeDisabled);
131-
const keyvalues = [];
130+
const properties = getMembersOfPropertyList(propertyList, includeDisabled),
131+
keyvalues = [];
132132

133133
properties.forEach((property) => {
134-
let keyvalue;
135-
if (trimRequestBody) {
136-
keyvalue = `${encodeURIComponent(property.key.trim())}=${encodeURIComponent(property.value.trim())}`;
137-
}
138-
else {
139-
keyvalue = `${encodeURIComponent(property.key)}=${encodeURIComponent(property.value)}`;
140-
}
134+
const key = trimRequestBody ? property.key.trim() : property.key,
135+
value = trimRequestBody ? property.value.trim() : property.value,
136+
keyvalue = `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
141137

142138
keyvalues.push(keyvalue);
143139
});

0 commit comments

Comments
 (0)