diff --git a/src/app/lib/parse-resume-from-pdf/extract-resume-from-sections/lib/feature-scoring-system.ts b/src/app/lib/parse-resume-from-pdf/extract-resume-from-sections/lib/feature-scoring-system.ts index 38a3abf..ae28d21 100644 --- a/src/app/lib/parse-resume-from-pdf/extract-resume-from-sections/lib/feature-scoring-system.ts +++ b/src/app/lib/parse-resume-from-pdf/extract-resume-from-sections/lib/feature-scoring-system.ts @@ -70,8 +70,9 @@ export const getTextWithHighestFeatureScore = ( if (returnEmptyStringIfHighestScoreIsNotPositive && highestScore <= 0) return ["", textScores] as const; + // Note: If textItems is an empty array, textsWithHighestFeatureScore[0] is undefined, so we default it to empty string const text = !returnConcatenatedStringForTextsWithSameHighestScore - ? textsWithHighestFeatureScore[0] + ? textsWithHighestFeatureScore[0] ?? "" : textsWithHighestFeatureScore.map((s) => s.trim()).join(" "); return [text, textScores] as const;