diff --git a/lib/main.dart b/lib/main.dart index d173f77e9..62355e518 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,6 +1,7 @@ import 'dart:isolate'; import 'dart:ui'; +import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:collection/collection.dart'; @@ -8,6 +9,7 @@ import 'package:flutter_secure_storage/flutter_secure_storage.dart'; import 'package:flutter_vodozemac/flutter_vodozemac.dart' as vod; import 'package:matrix/matrix.dart'; import 'package:shared_preferences/shared_preferences.dart'; +import 'package:universal_html/universal_html.dart' as web; import 'package:fluffychat/config/app_config.dart'; import 'package:fluffychat/utils/client_manager.dart'; @@ -30,6 +32,14 @@ void main() async { await waitForPushIsolateDone(); } + // Sanitize hash for OIDC: + if (kIsWeb) { + final hash = web.window.location.hash; + if (hash.isNotEmpty && !hash.startsWith('/')) { + web.window.location.hash = hash.replaceFirst('#', '#?'); + } + } + // Our background push shared isolate accesses flutter-internal things very early in the startup proccess // To make sure that the parts of flutter needed are started up already, we need to ensure that the // widget bindings are initialized already.