Skip to content

Commit

Permalink
Test for type and state_key being strings, not being truthy
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Paul committed Aug 10, 2020
1 parent 5739e65 commit deb2f38
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/components/state-lookup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,7 @@ export class StateLookup {
return es[eventType][stateKey] || null;
}

return Object.keys(es[eventType]).map(function(skey) {
return es[eventType][skey];
});
return Object.keys(es[eventType]).map(skey => es[eventType][skey]);
}

private async getInitialState(roomId: string): Promise<StateLookupRoom> {
Expand Down Expand Up @@ -195,8 +193,8 @@ export class StateLookup {
// Reject - unexpected content type
return;
}
if (!event.type || !event.state_key) {
// Reject - missing keys
if (typeof event.type !== "string" || typeof event.state_key !== "string") {
// Reject - invalid keys
return;
}
// blunt update
Expand Down

0 comments on commit deb2f38

Please sign in to comment.