Skip to content

Commit 422abf1

Browse files
authored
Protect against undefined semesters
1 parent 2d08b89 commit 422abf1

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

src/lib/utils/schema.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,8 @@ export function setImageHeight(src: string, height: number): string {
155155
}
156156

157157
export function parseSemester(semester: string): Semester {
158+
if (!semester) return { season: "", year: 0 }; // protect againt undefined semester
159+
158160
const [season, yearString] = semester.split(" ");
159161

160162
const year = parseInt(yearString);
@@ -163,6 +165,7 @@ export function parseSemester(semester: string): Semester {
163165
}
164166

165167
export function semesterToId(semester: string): string {
168+
if (!semester) return ""; // protect againt undefined semester
166169
return semester.split(" ").join("-").toLowerCase();
167170
}
168171

0 commit comments

Comments
 (0)