mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-31 16:18:22 +08:00
mod: isRedirect (#866)
This commit is contained in:
committed by
GitHub
parent
3993ff8a8e
commit
f29385ccef
@@ -19,18 +19,17 @@ class UrlUtils {
|
|||||||
final response = await Request.dio.head(
|
final response = await Request.dio.head(
|
||||||
url,
|
url,
|
||||||
options: Options(
|
options: Options(
|
||||||
followRedirects: false,
|
followRedirects: false,
|
||||||
validateStatus: (status) {
|
validateStatus: (status) {
|
||||||
return 200 <= status! && status < 400;
|
return 200 <= status! && status < 400;
|
||||||
},
|
},
|
||||||
extra: {'account': AnonymousAccount()}),
|
extra: {'account': AnonymousAccount()},
|
||||||
|
),
|
||||||
);
|
);
|
||||||
if (response.isRedirect) {
|
redirectUrl = response.headers['location']?.firstOrNull;
|
||||||
redirectUrl = response.headers['location']?.firstOrNull;
|
debugPrint('redirectUrl: $redirectUrl');
|
||||||
debugPrint('redirectUrl: $redirectUrl');
|
if (redirectUrl != null && !redirectUrl.startsWith('http')) {
|
||||||
if (redirectUrl != null && !redirectUrl.startsWith('http')) {
|
redirectUrl = Uri.parse(url).resolve(redirectUrl).toString();
|
||||||
redirectUrl = Uri.parse(url).resolve(redirectUrl).toString();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
if (returnOri && redirectUrl == null) redirectUrl = url;
|
if (returnOri && redirectUrl == null) redirectUrl = url;
|
||||||
|
|||||||
Reference in New Issue
Block a user