fix: 评论区@跟jumpUrl共存时链接解析 issues #404
This commit is contained in:
@ -552,7 +552,7 @@ InlineSpan buildContent(
|
||||
);
|
||||
}
|
||||
final List<InlineSpan> spanChilds = <InlineSpan>[];
|
||||
bool hasMatchMember = true;
|
||||
bool hasMatchMember = false;
|
||||
|
||||
// 投票
|
||||
if (content.vote.isNotEmpty) {
|
||||
@ -643,7 +643,7 @@ InlineSpan buildContent(
|
||||
reg,
|
||||
onMatch: (Match match) {
|
||||
if (match[0] != null) {
|
||||
hasMatchMember = false;
|
||||
hasMatchMember = true;
|
||||
content.atNameToMid.forEach((key, value) {
|
||||
if (str.contains('回复')) {
|
||||
spanChilds.add(
|
||||
@ -682,6 +682,7 @@ InlineSpan buildContent(
|
||||
if (!str.contains('@')) {
|
||||
spanChilds.add(TextSpan(text: str));
|
||||
}
|
||||
print(str);
|
||||
return str;
|
||||
},
|
||||
);
|
||||
@ -691,7 +692,7 @@ InlineSpan buildContent(
|
||||
|
||||
// 匹配 jumpUrl
|
||||
String matchUrl = matchMember;
|
||||
if (content.jumpUrl.isNotEmpty && hasMatchMember) {
|
||||
if (content.jumpUrl.isNotEmpty) {
|
||||
final List urlKeys = content.jumpUrl.keys.toList().reversed.toList();
|
||||
for (int index = 0; index < urlKeys.length; index++) {
|
||||
var i = urlKeys[index];
|
||||
@ -705,6 +706,11 @@ InlineSpan buildContent(
|
||||
urlKeys[index] = i.replaceAll('*', '\\*');
|
||||
}
|
||||
}
|
||||
if (hasMatchMember) {
|
||||
matchMember = matchMember.split('回复 @ :').length > 1
|
||||
? matchMember.split('回复 @ :')[1]
|
||||
: matchMember;
|
||||
}
|
||||
matchUrl = matchMember.splitMapJoin(
|
||||
/// RegExp.escape() 转义特殊字符
|
||||
RegExp(urlKeys.map((key) => key).join("|")),
|
||||
|
@ -49,8 +49,8 @@ class IdUtils {
|
||||
|
||||
// 匹配
|
||||
static Map<String, dynamic> matchAvorBv({String? input}) {
|
||||
final Map<String, dynamic> result = {'': null};
|
||||
if (input == null || input == '') {
|
||||
final Map<String, dynamic> result = {};
|
||||
if (input == null || input.isEmpty) {
|
||||
return result;
|
||||
}
|
||||
final RegExp bvRegex = RegExp(r'BV[0-9A-Za-z]{10}', caseSensitive: false);
|
||||
|
Reference in New Issue
Block a user