Skip to content

Commit

Permalink
Fix schedule null api URL (#1316)
Browse files Browse the repository at this point in the history
  • Loading branch information
DGoiana authored Sep 10, 2024
2 parents 5c2936b + 593a4cd commit 0947552
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ class ScheduleFetcherNewApi extends ScheduleFetcher {

final scheduleApiUrl = getScheduleApiUrlFromHtml(scheduleResponse);

if (scheduleApiUrl == null) {
return <Lecture>[];
}

final scheduleApiResponse = await NetworkRouter.getWithCookies(
scheduleApiUrl,
{},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,14 @@ import 'package:uni/model/entities/lecture.dart';
/// Extracts the user's lecture API URL.
///
/// This function parses the schedule's HTML page.
String getScheduleApiUrlFromHtml(
String? getScheduleApiUrlFromHtml(
http.Response response,
) {
final document = parse(response.body);

final scheduleElement = document.querySelector('#cal-shadow-container');
final apiUrl = scheduleElement?.attributes['data-evt-source-url'];

if (apiUrl == null) {
throw Exception('Could not find schedule API URL in schedule page');
}

return apiUrl;
}

Expand Down

0 comments on commit 0947552

Please sign in to comment.