Skip to content

Commit 9d123f2

Browse files
authored
Merge pull request #181 from lifeomic/handle-multiValueQueryStringParameters
fix!: Add Support for multiValueQueryStringParameters
2 parents f4f2fd2 + f3acd81 commit 9d123f2

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/adapters/helpers/lambdaEvent.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@ export const lambdaEvent = (config: AlphaOptions, relativeUrl?: string) => {
1414
querystringWithArraySupport,
1515
);
1616
const params = Object.assign({}, parts.query, config.params);
17+
const multiValueQueryStringParameters: Record<string, any> = { ...params };
18+
19+
Object.keys(multiValueQueryStringParameters).forEach((key) => {
20+
if (!Array.isArray(multiValueQueryStringParameters[key])) {
21+
delete multiValueQueryStringParameters[key];
22+
} else {
23+
delete params[key];
24+
}
25+
});
1726

1827
const httpMethod = (config.method as string).toUpperCase();
1928
const requestTime = new Date();
@@ -64,7 +73,7 @@ export const lambdaEvent = (config: AlphaOptions, relativeUrl?: string) => {
6473
userArn: null,
6574
},
6675
},
67-
multiValueQueryStringParameters: null,
76+
multiValueQueryStringParameters,
6877
};
6978

7079
if (Buffer.isBuffer(event.body)) {

test/lambda-event.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,14 @@ test('Can parse URLs with duplicate parameters', () => {
3131
httpMethod: 'GET',
3232
path: '/lifeomic/dstu3/Questionnaire',
3333
queryStringParameters: {
34+
pageSize: '25',
35+
},
36+
multiValueQueryStringParameters: {
3437
_tag: [
3538
'http://lifeomic.com/fhir/questionnaire-type|survey-form',
3639
'http://lifeomic.com/fhir/dataset|0bb18fef-4e2d-4b91-a623-09527265a8b3',
3740
'http://lifeomic.com/fhir/primary|0343bfcf-4e2d-4b91-a623-095272783bf3',
3841
],
39-
pageSize: '25',
4042
},
4143
}));
4244
assertRequestId(result);
@@ -55,6 +57,7 @@ test('Can parse URLs without duplicates', () => {
5557
pageSize: '25',
5658
test: 'diffValue',
5759
},
60+
multiValueQueryStringParameters: {},
5861
}));
5962
assertRequestId(result);
6063
});

0 commit comments

Comments
 (0)