fix: pathSegments越界

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

View File

@ -52,15 +52,19 @@ 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;
final Map matchRes = IdUtils.matchAvorBv(input: str); if (pathSegments.isNotEmpty &&
final List matchKeys = matchRes.keys.toList(); url != 'https://passport.bilibili.com/h5-app/passport/login') {
if (matchKeys.isNotEmpty) { final String str = pathSegments[0];
if (matchKeys.first == 'BV') { final Map matchRes = IdUtils.matchAvorBv(input: str);
Get.offAndToNamed( final List matchKeys = matchRes.keys.toList();
'/searchResult', if (matchKeys.isNotEmpty) {
parameters: {'keyword': matchRes['BV']}, if (matchKeys.first == 'BV') {
); Get.offAndToNamed(
'/searchResult',
parameters: {'keyword': matchRes['BV']},
);
}
} }
} }
}, },