40 lines
1.3 KiB
Dart
40 lines
1.3 KiB
Dart
import '../school_navigation_policy.dart';
|
|
|
|
class UndergraduateNavigationPolicy {
|
|
static bool canNavigate(Uri uri, {required bool isMainFrame}) =>
|
|
uri.scheme == 'https' &&
|
|
uri.port == 443 &&
|
|
uri.userInfo.isEmpty &&
|
|
const {
|
|
'eams.uestc.edu.cn',
|
|
'idas.uestc.edu.cn',
|
|
'eportal.uestc.edu.cn',
|
|
}.contains(uri.host) ||
|
|
!isMainFrame && uri.toString() == 'about:blank';
|
|
static bool isDataPage(Uri uri) =>
|
|
canNavigate(uri, isMainFrame: true) &&
|
|
uri.host == 'eams.uestc.edu.cn' &&
|
|
uri.path.startsWith('/eams/');
|
|
static bool isLogout(Uri uri) =>
|
|
isDataPage(uri) && uri.path == '/eams/logout.action';
|
|
static Uri? secureIdentityRedirect(Uri uri) {
|
|
final identity = SchoolNavigationPolicy.secureIdentityRedirect(uri);
|
|
if (identity != null) return identity;
|
|
// Legacy duplicate-login links use HTTP even within the HTTPS portal.
|
|
if (uri.scheme != 'http' ||
|
|
uri.host != 'eams.uestc.edu.cn' ||
|
|
uri.port != 80 ||
|
|
uri.userInfo.isNotEmpty ||
|
|
!(uri.path == '/eams' || uri.path.startsWith('/eams/'))) {
|
|
return null;
|
|
}
|
|
return Uri(
|
|
scheme: 'https',
|
|
host: uri.host,
|
|
path: uri.path,
|
|
query: uri.hasQuery ? uri.query : null,
|
|
fragment: uri.hasFragment ? uri.fragment : null,
|
|
);
|
|
}
|
|
}
|