Skip to content

Commit

Permalink
Update path parameter to follow RFC/generic HTTP convention (#737)
Browse files Browse the repository at this point in the history
* Update path parameter to follow RFC/generic HTTP convention

Signed-off-by: suzhou <suzhou@amazon.com>

* Update path parameter to follow RFC/generic HTTP convention

Signed-off-by: suzhou <suzhou@amazon.com>

---------

Signed-off-by: suzhou <suzhou@amazon.com>
  • Loading branch information
SuZhou-Joe authored May 17, 2023
1 parent cc93576 commit a4a6a8d
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion server/services/CommonService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,14 @@ export default class IndexService {
const useQuery = !request.body;
const usedParam = (useQuery ? request.query : request.body) as IAPICaller;
const { endpoint, data } = usedParam || {};
const payload = useQuery ? JSON.parse(data || "{}") : data;
const finalData = data;
/**
* Update path parameter to follow RFC/generic HTTP convention
*/
if (endpoint === "transport.request" && typeof finalData?.path === "string" && !/^\//.test(finalData?.path || "")) {
finalData.path = `/${finalData.path || ""}`;
}
const payload = useQuery ? JSON.parse(finalData || "{}") : finalData;
const commonCallerResponse = await callWithRequest(endpoint, payload || {});
return response.custom({
statusCode: 200,
Expand Down

0 comments on commit a4a6a8d

Please sign in to comment.