Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix replacing substring of params in search query #1226

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
15 changes: 5 additions & 10 deletions projects/lib/src/oauth-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1745,16 +1745,11 @@ export class OAuthService extends AuthConfig implements OnDestroy {
location.origin +
location.pathname +
location.search
.replace(/code=[^&\$]*/, '')
.replace(/scope=[^&\$]*/, '')
.replace(/state=[^&\$]*/, '')
.replace(/session_state=[^&\$]*/, '')
.replace(/^\?&/, '?')
.replace(/&$/, '')
.replace(/^\?$/, '')
.replace(/&+/g, '&')
.replace(/\?&/, '?')
.replace(/\?$/, '') +
Comment on lines -1752 to -1757
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new way of matching will result in less situations that can break the format of the URL that's why these replace are not needed anymore.

.replace(/[&?]code=[^&\$]*/, '')
.replace(/[&?]scope=[^&\$]*/, '')
.replace(/[&?]state=[^&\$]*/, '')
.replace(/[&?]session_state=[^&\$]*/, '')
.replace(/^&/, '?') +
location.hash;

history.replaceState(null, window.name, href);
Expand Down