diff --git a/projects/lib/src/oauth-service.ts b/projects/lib/src/oauth-service.ts index 6f0bce0f..ed9df44c 100644 --- a/projects/lib/src/oauth-service.ts +++ b/projects/lib/src/oauth-service.ts @@ -1629,11 +1629,14 @@ export class OAuthService extends AuthConfig implements OnDestroy { const sessionState = parts['session_state']; if (!options.preventClearHashAfterLogin) { - const href = location.href - .replace(/[&\?]code=[^&\$]*/, '') - .replace(/[&\?]scope=[^&\$]*/, '') - .replace(/[&\?]state=[^&\$]*/, '') - .replace(/[&\?]session_state=[^&\$]*/, ''); + const href = location.origin + location.pathname + + location.search.replace(/code=[^&\$]*/, '') + .replace(/scope=[^&\$]*/, '') + .replace(/state=[^&\$]*/, '') + .replace(/session_state=[^&\$]*/, '') + .replace(/^\?&/, '?') + .replace(/&$/, '') + .replace(/^\?$/, '') + location.hash; history.replaceState(null, window.name, href); }