Skip to content

Commit 475a93b

Browse files
committed
fix: parse method mutating its input
1 parent 5ab8164 commit 475a93b

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/lib/bindings/http/validation/structured.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,20 @@ function parse(payload, headers, receiver) {
3232
source: undefined
3333
};
3434

35+
36+
const unprocessed = new Set(Object.keys(incoming));
37+
3538
receiver.parserMap.forEach((value, key) => {
3639
if (incoming[key]) {
3740
event[value.name] = value.parser(incoming[key]);
38-
delete incoming[key];
41+
unprocessed.delete(key);
3942
}
4043
});
4144

4245
const cloudevent = new CloudEvent(event);
4346

4447
// Every unprocessed attribute should be an extension
45-
Array.from(Object.keys(incoming)).forEach((extension) =>
48+
unprocessed.forEach((extension) =>
4649
cloudevent.addExtension(extension, incoming[extension]));
4750

4851
cloudevent.spec.check();

0 commit comments

Comments
 (0)