Skip to content

Commit

Permalink
fix(PlainTextParser): check answers before use
Browse files Browse the repository at this point in the history
Should fix crash in Sentry.
  • Loading branch information
aalemayhu committed Jul 18, 2023
1 parent af45368 commit f62bf83
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ import {
export class PlainTextParser {
getOneOrMoreAnswers(answers: string): string[] {
const answerList = answers.split(', ');
if (!answerList || answerList.length === 0) {

if (answerList.length === 0) {
return [answers];
}

return answerList;
}

Expand Down Expand Up @@ -47,7 +49,7 @@ export class PlainTextParser {
for (const bulletPoint of bulletPoints) {
const [question, answers] = bulletPoint.split(' - ');

if (isPossiblyClozeFlashcard(question)) {
if (answers && isPossiblyClozeFlashcard(question)) {
const cards = this.fillInTheBlanks(question, answers);
if (cards) {
flashcards.push(cards);
Expand Down

0 comments on commit f62bf83

Please sign in to comment.