Skip to content

Commit

Permalink
fix: url params with front slash encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
stephanoshadjipetrou committed Oct 7, 2024
1 parent cb51766 commit eddb4c2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
3 changes: 2 additions & 1 deletion src/controllers/allocations.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,9 @@ export class AllocationsController {
async allocationsRadialChartInLocation(
@param.path.string('countryCode') countryCode: string,
) {
const decodedCode = countryCode.replace(/\|/g, '%2F');
let filterString = filterFinancialIndicators(
{...this.req.query, geographies: countryCode},
{...this.req.query, geographies: decodedCode},
AllocationRadialFieldsMapping.urlParamsLocation,
'geography/code',
'activityArea/name',
Expand Down
28 changes: 20 additions & 8 deletions src/controllers/location.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,19 @@ export class LocationController {
@get('/location/{code}/grants/pie-charts')
@response(200)
async locationGrantsPieCharts(@param.path.string('code') code: string) {
let filterString1 = PieChartsMapping.pie1UrlParams.replace('<code>', code);
let filterString2 = PieChartsMapping.pie2UrlParams.replace('<code>', code);
let filterString3 = PieChartsMapping.pie3UrlParams.replace('<code>', code);
const decodedCode = code.replace(/\|/g, '%2F');
let filterString1 = PieChartsMapping.pie1UrlParams.replace(
'<code>',
decodedCode,
);
let filterString2 = PieChartsMapping.pie2UrlParams.replace(
'<code>',
decodedCode,
);
let filterString3 = PieChartsMapping.pie3UrlParams.replace(
'<code>',
decodedCode,
);
filterString1 = filterString1.replace('<filterString>', '');
filterString2 = filterString2.replace('<filterString>', '');
filterString3 = filterString3.replace('<filterString>', '');
Expand Down Expand Up @@ -302,25 +312,26 @@ export class LocationController {
@get('/location/{code}/info')
@response(200)
async locationInfo(@param.path.string('code') code: string) {
const decodedCode = code.replace(/\|/g, '%2F');
const url = `${urls.GEOGRAPHIES}/${LocationInfoMapping.urlParams.replace(
'<code>',
code,
decodedCode,
)}`;
const FPMurl = `${urls.GRANTS}/${LocationInfoMapping.FPMurlParams.replace(
'<code>',
code,
decodedCode,
)}`;
const currPrincipalRecipientsUrl = `${
urls.GRANTS
}/${LocationInfoMapping.currentPrincipalRecipientsUrlParams.replace(
'<code>',
code,
decodedCode,
)}`;
const formerPrincipalRecipientsUrl = `${
urls.GRANTS
}/${LocationInfoMapping.formerPrincipalRecipientsUrlParams.replace(
'<code>',
code,
decodedCode,
)}`;

return axios
Expand Down Expand Up @@ -413,9 +424,10 @@ export class LocationController {
async locationCoordinatingMechanismContacts(
@param.path.string('code') code: string,
) {
const decodedCode = code.replace(/\|/g, '%2F');
const filterString = CoordinatingMehanismContactsMapping.urlParams.replace(
'<code>',
code,
decodedCode,
);
const url = `${urls.COORDINATING_MECHANISMS}/${filterString}`;

Expand Down

0 comments on commit eddb4c2

Please sign in to comment.