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