opt: handle url

Closes #143

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-01-12 09:27:36 +08:00
parent 0817b183a4
commit e645274609
4 changed files with 45 additions and 26 deletions

View File

@@ -777,7 +777,6 @@ class ReplyItem extends StatelessWidget {
if (matchStr.startsWith('BV')) {
UrlUtils.matchUrlPush(
matchStr,
title,
'',
);
} else if (RegExp(r'^[Cc][Vv][0-9]+$')
@@ -834,7 +833,6 @@ class ReplyItem extends StatelessWidget {
if (lastPathSegment.startsWith('BV')) {
UrlUtils.matchUrlPush(
lastPathSegment,
title,
redirectUrl,
);
} else {
@@ -876,7 +874,26 @@ class ReplyItem extends StatelessWidget {
color: Theme.of(context).colorScheme.primary,
),
recognizer: TapGestureRecognizer()
..onTap = () => Utils.handleWebview(matchStr),
..onTap = () async {
if (matchStr.startsWith('https://b23.tv')) {
final String redirectUrl =
(await UrlUtils.parseRedirectUrl(matchStr)) ??
matchStr;
final String pathSegment = Uri.parse(redirectUrl).path;
final String lastPathSegment =
pathSegment.split('/').last;
if (lastPathSegment.startsWith('BV')) {
UrlUtils.matchUrlPush(
lastPathSegment,
redirectUrl,
);
} else {
PiliScheme.routePush(Uri.parse(matchStr));
}
} else {
PiliScheme.routePush(Uri.parse(matchStr));
}
},
),
);
} else {