Skip to content

Commit 44b021b

Browse files
committed
fix: Add Support for multiValueQueryStringParameters
1 parent f4f2fd2 commit 44b021b

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/adapters/helpers/lambdaEvent.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ 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+
}
23+
});
1724

1825
const httpMethod = (config.method as string).toUpperCase();
1926
const requestTime = new Date();
@@ -64,7 +71,10 @@ export const lambdaEvent = (config: AlphaOptions, relativeUrl?: string) => {
6471
userArn: null,
6572
},
6673
},
67-
multiValueQueryStringParameters: null,
74+
multiValueQueryStringParameters:
75+
Object.keys(multiValueQueryStringParameters).length > 0
76+
? multiValueQueryStringParameters
77+
: null,
6878
};
6979

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

test/lambda-event.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ test('Can parse URLs with duplicate parameters', () => {
3838
],
3939
pageSize: '25',
4040
},
41+
multiValueQueryStringParameters: {
42+
_tag: [
43+
'http://lifeomic.com/fhir/questionnaire-type|survey-form',
44+
'http://lifeomic.com/fhir/dataset|0bb18fef-4e2d-4b91-a623-09527265a8b3',
45+
'http://lifeomic.com/fhir/primary|0343bfcf-4e2d-4b91-a623-095272783bf3',
46+
],
47+
},
4148
}));
4249
assertRequestId(result);
4350
});
@@ -55,6 +62,7 @@ test('Can parse URLs without duplicates', () => {
5562
pageSize: '25',
5663
test: 'diffValue',
5764
},
65+
multiValueQueryStringParameters: null,
5866
}));
5967
assertRequestId(result);
6068
});

0 commit comments

Comments
 (0)