fix: force H5 shell to use canonical web host

This commit is contained in:
Booker
2026-05-26 21:57:03 +07:00
parent cfae597b9d
commit 2aa7a9dda9
3 changed files with 82 additions and 14 deletions

View File

@@ -47,4 +47,22 @@ void main() {
expect(Uri.splitQueryString(uri.fragment).containsKey('shell_app_logo'),
isFalse);
});
test('rewrites legacy H5 host main-frame URLs to the canonical host', () {
final uri = Uri.parse(
AppConfig.canonicalizeMainFrameUrl(
'https://h5-test.imharry.work/login?from=runtime'
'&shell_app_name=Old#shell_app_logo=old',
),
);
expect(uri.scheme, 'https');
expect(uri.host, 'h5-im.imharry.work');
expect(uri.path, '/login');
expect(uri.queryParameters['from'], 'runtime');
expect(uri.queryParameters.containsKey('_h5_t'), isTrue);
expect(uri.queryParameters.containsKey('shell_app_name'), isFalse);
expect(Uri.splitQueryString(uri.fragment).containsKey('shell_app_logo'),
isFalse);
});
}