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.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());
}