fix: force H5 shell to use canonical web host
This commit is contained in:
@@ -304,6 +304,8 @@ class _H5ShellPageState extends State<H5ShellPage> {
|
||||
}
|
||||
|
||||
Future<void> _loadUrl(String url) async {
|
||||
final targetUrl = AppConfig.canonicalizeMainFrameUrl(url);
|
||||
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_loadError = null;
|
||||
@@ -313,7 +315,7 @@ class _H5ShellPageState extends State<H5ShellPage> {
|
||||
}
|
||||
|
||||
await _clearWebViewHttpCache();
|
||||
await _controller.loadRequest(Uri.parse(url));
|
||||
await _controller.loadRequest(Uri.parse(targetUrl));
|
||||
}
|
||||
|
||||
Future<void> _clearWebViewHttpCache() async {
|
||||
@@ -334,6 +336,11 @@ class _H5ShellPageState extends State<H5ShellPage> {
|
||||
|
||||
const webSchemes = {'http', 'https', 'about', 'data'};
|
||||
if (webSchemes.contains(uri.scheme)) {
|
||||
if (request.isMainFrame &&
|
||||
AppConfig.shouldRewriteMainFrameUrl(request.url)) {
|
||||
unawaited(_loadUrl(AppConfig.canonicalizeMainFrameUrl(request.url)));
|
||||
return NavigationDecision.prevent;
|
||||
}
|
||||
return NavigationDecision.navigate;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user