mod: 评论区非正常地址判断
This commit is contained in:
@ -642,6 +642,11 @@ InlineSpan buildContent(
|
|||||||
} else {
|
} else {
|
||||||
final String redirectUrl =
|
final String redirectUrl =
|
||||||
await UrlUtils.parseRedirectUrl(matchStr);
|
await UrlUtils.parseRedirectUrl(matchStr);
|
||||||
|
if (redirectUrl == matchStr) {
|
||||||
|
Clipboard.setData(ClipboardData(text: matchStr));
|
||||||
|
SmartDialog.showToast('地址可能有误');
|
||||||
|
return;
|
||||||
|
}
|
||||||
final String pathSegment = Uri.parse(redirectUrl).path;
|
final String pathSegment = Uri.parse(redirectUrl).path;
|
||||||
final String lastPathSegment =
|
final String lastPathSegment =
|
||||||
pathSegment.split('/').last;
|
pathSegment.split('/').last;
|
||||||
|
|||||||
@ -14,6 +14,7 @@ class UrlUtils {
|
|||||||
dio.options.validateStatus = (status) {
|
dio.options.validateStatus = (status) {
|
||||||
return status == 200 || status == 301 || status == 302;
|
return status == 200 || status == 301 || status == 302;
|
||||||
};
|
};
|
||||||
|
try {
|
||||||
final response = await dio.get(url);
|
final response = await dio.get(url);
|
||||||
if (response.statusCode == 302) {
|
if (response.statusCode == 302) {
|
||||||
redirectUrl = response.headers['location']?.first as String;
|
redirectUrl = response.headers['location']?.first as String;
|
||||||
@ -27,6 +28,9 @@ class UrlUtils {
|
|||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
return redirectUrl;
|
return redirectUrl;
|
||||||
|
} catch (err) {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 匹配url路由跳转
|
// 匹配url路由跳转
|
||||||
|
|||||||
Reference in New Issue
Block a user