Skip to content

Commit a9e0f8c

Browse files
committed
fix: empty params are handled as if they were not provided at all
1 parent 3397d65 commit a9e0f8c

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

lib/helpers/params.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ module.exports = function getParams(whitelist) {
1010

1111
const klass = class Params {
1212
constructor(params) {
13-
whitelist.forEach((prop) => { this[prop] = params[prop]; });
13+
whitelist.forEach((prop) => {
14+
this[prop] = params[prop] || undefined;
15+
});
1416
}
1517

1618
toPlainObject() {

lib/helpers/validate_presence.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ const { InvalidRequest } = require('./errors');
33
module.exports = function validatePresence(ctx, ...required) {
44
const { params } = ctx.oidc;
55
const missing = required.map((param) => {
6-
if (params[param] === undefined) return param;
6+
if (params[param] === undefined) {
7+
return param;
8+
}
9+
710
return undefined;
811
}).filter(Boolean);
912

test/body_parser/body_parser.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ describe('body parser', () => {
7878
.expect(200);
7979

8080
expect(
81-
spy.calledWithMatch({ oidc: { params: { scope: '' } } }),
81+
spy.calledWithMatch({ oidc: { params: { scope: undefined } } }),
8282
).to.be.true;
8383
});
8484
});

0 commit comments

Comments
 (0)