post_enrollment_app/lib/pages/helpers/browser_href_web.dart
2026-05-19 12:30:28 +05:30

23 lines
785 B
Dart

import 'dart:html' as html;
String currentBrowserHref() => html.window.location.href;
/// Removes `payload` from the query string so a failed SSO return does not
/// re-trigger handling when [GoRouter] rebuilds `/login`.
void stripPayloadParamFromBrowserUrl() {
final u = Uri.parse(html.window.location.href);
if (!u.queryParameters.containsKey('payload')) return;
final m = Map<String, String>.from(u.queryParameters);
m.remove('payload');
final clean = Uri(
scheme: u.scheme,
userInfo: u.userInfo.isEmpty ? null : u.userInfo,
host: u.host.isEmpty ? null : u.host,
port: u.hasPort ? u.port : null,
path: u.path,
queryParameters: m.isEmpty ? null : m,
fragment: u.fragment,
);
html.window.history.replaceState(null, '', clean.toString());
}