Skip to content

Commit

Permalink
fix(core): do not crash the vote count in case of invalid ballot (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
aduh95 authored Jun 26, 2024
1 parent dac0a32 commit 4fcce30
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/core/src/vote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export default class Vote {
}

public addBallotFile(ballotData: BallotFileFormat, author?: string): Ballot {
if (checkBallot(ballotData, this.voteFileData, author)) {
if (ballotData && checkBallot(ballotData, this.voteFileData, author)) {
const preferences: Map<VoteCandidate, Rank> = new Map(
ballotData.preferences.map((element) => [element.title, element.score])
);
Expand All @@ -154,7 +154,7 @@ export default class Vote {
this.addBallot(ballot);
return ballot;
} else {
console.warn("Invalid Ballot");
console.warn("Invalid Ballot", author);
}
return null;
}
Expand Down

0 comments on commit 4fcce30

Please sign in to comment.