fix: pathSegments越界

This commit is contained in:
guozhigq
2024-05-07 23:10:27 +08:00
parent 32f392af64
commit 27c05665aa

View File

@ -52,7 +52,10 @@ class WebviewController extends GetxController {
loadProgress.value = progress; loadProgress.value = progress;
}, },
onPageStarted: (String url) { onPageStarted: (String url) {
final String str = Uri.parse(url).pathSegments[0]; final List pathSegments = Uri.parse(url).pathSegments;
if (pathSegments.isNotEmpty &&
url != 'https://passport.bilibili.com/h5-app/passport/login') {
final String str = pathSegments[0];
final Map matchRes = IdUtils.matchAvorBv(input: str); final Map matchRes = IdUtils.matchAvorBv(input: str);
final List matchKeys = matchRes.keys.toList(); final List matchKeys = matchRes.keys.toList();
if (matchKeys.isNotEmpty) { if (matchKeys.isNotEmpty) {
@ -63,6 +66,7 @@ class WebviewController extends GetxController {
); );
} }
} }
}
}, },
// 加载完成 // 加载完成
onUrlChange: (UrlChange urlChange) async { onUrlChange: (UrlChange urlChange) async {