Skip to content

Commit

Permalink
Merge pull request #181 from lifeomic/handle-multiValueQueryStringPar…
Browse files Browse the repository at this point in the history
…ameters

fix!: Add Support for multiValueQueryStringParameters
  • Loading branch information
sternetj authored Nov 4, 2024
2 parents f4f2fd2 + f3acd81 commit 9d123f2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
11 changes: 10 additions & 1 deletion src/adapters/helpers/lambdaEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ export const lambdaEvent = (config: AlphaOptions, relativeUrl?: string) => {
querystringWithArraySupport,
);
const params = Object.assign({}, parts.query, config.params);
const multiValueQueryStringParameters: Record<string, any> = { ...params };

Object.keys(multiValueQueryStringParameters).forEach((key) => {
if (!Array.isArray(multiValueQueryStringParameters[key])) {
delete multiValueQueryStringParameters[key];
} else {
delete params[key];
}
});

const httpMethod = (config.method as string).toUpperCase();
const requestTime = new Date();
Expand Down Expand Up @@ -64,7 +73,7 @@ export const lambdaEvent = (config: AlphaOptions, relativeUrl?: string) => {
userArn: null,
},
},
multiValueQueryStringParameters: null,
multiValueQueryStringParameters,
};

if (Buffer.isBuffer(event.body)) {
Expand Down
5 changes: 4 additions & 1 deletion test/lambda-event.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,14 @@ test('Can parse URLs with duplicate parameters', () => {
httpMethod: 'GET',
path: '/lifeomic/dstu3/Questionnaire',
queryStringParameters: {
pageSize: '25',
},
multiValueQueryStringParameters: {
_tag: [
'http://lifeomic.com/fhir/questionnaire-type|survey-form',
'http://lifeomic.com/fhir/dataset|0bb18fef-4e2d-4b91-a623-09527265a8b3',
'http://lifeomic.com/fhir/primary|0343bfcf-4e2d-4b91-a623-095272783bf3',
],
pageSize: '25',
},
}));
assertRequestId(result);
Expand All @@ -55,6 +57,7 @@ test('Can parse URLs without duplicates', () => {
pageSize: '25',
test: 'diffValue',
},
multiValueQueryStringParameters: {},
}));
assertRequestId(result);
});
Expand Down

0 comments on commit 9d123f2

Please sign in to comment.