opt: jump url (#246)

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
dom
2025-02-13 16:53:40 +08:00
committed by GitHub
parent ba74cb8c01
commit 54c7fef217
17 changed files with 594 additions and 656 deletions

View File

@@ -1,4 +1,5 @@
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';
@@ -9,8 +10,10 @@ import 'utils.dart';
class UrlUtils {
// 302重定向路由截取
static Future<String?> parseRedirectUrl(String url,
[bool returnOri = false]) async {
static Future<String?> parseRedirectUrl(
String url, [
bool returnOri = false,
]) async {
try {
final response = await Request().get(
url,
@@ -23,9 +26,10 @@ class UrlUtils {
);
if (response.statusCode == 302 || response.statusCode == 301) {
String? redirectUrl = response.headers['location']?.first;
debugPrint('redirectUrl: $redirectUrl');
if (redirectUrl != null) {
if (redirectUrl.startsWith('/')) {
return url;
return returnOri ? url : null;
}
if (redirectUrl.endsWith('/')) {
redirectUrl = redirectUrl.substring(0, redirectUrl.length - 1);