Skip to content

Commit

Permalink
fix: fix encodeURIComponent in query serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
Anton Koshkin authored and raveclassic committed Dec 6, 2019
1 parent e5cca53 commit d7229d3
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/language/typescript/2.0/serializers/operation-object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,11 @@ export const serializeQueryParameterObject = (
case 'integer':
case 'number':
case 'boolean': {
const f = serializedFragment(`value => encodeURIComponent('${parameter.name}=' + value)`, [], []);
const f = serializedFragment(
`value => encodeURIComponent('${parameter.name}') + '=' + encodeURIComponent(value)`,
[],
[],
);
return right(getSerializedOptionCallFragment(!required, f, encoded));
}
case 'array': {
Expand All @@ -416,15 +420,19 @@ export const serializeQueryParameterObject = (
case 'pipes': {
const s = getCollectionSeparator(collectionFormat);
const f = serializedFragment(
`value => encodeURIComponent('${parameter.name}=' + value.join('${s}'))`,
`value => encodeURIComponent('${
parameter.name
}') + '=' + encodeURIComponent(value.join('${s}'))`,
[],
[],
);
return right(getSerializedOptionCallFragment(!required, f, encoded));
}
case 'multi': {
const f = serializedFragment(
`value => value.map(item => encodeURIComponent('${parameter.name}=' + item)).join('&')`,
`value => value.map(item => encodeURIComponent('${
parameter.name
}') + '=' + encodeURIComponent(item)).join('&')`,
[],
[],
);
Expand Down

0 comments on commit d7229d3

Please sign in to comment.