Skip to content

Commit 70fd826

Browse files
authored
fix: correctly handle ? and & in location replacements
1 parent 9e257d0 commit 70fd826

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

projects/lib/src/oauth-service.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1630,10 +1630,13 @@ export class OAuthService extends AuthConfig implements OnDestroy {
16301630

16311631
if (!options.preventClearHashAfterLogin) {
16321632
const href = location.origin + location.pathname +
1633-
location.search.replace(/[&\?]code=[^&\$]*/, '')
1634-
.replace(/[&\?]scope=[^&\$]*/, '')
1635-
.replace(/[&\?]state=[^&\$]*/, '')
1636-
.replace(/[&\?]session_state=[^&\$]*/, '') + location.hash;
1633+
location.search.replace(/code=[^&\$]*/, '')
1634+
.replace(/scope=[^&\$]*/, '')
1635+
.replace(/state=[^&\$]*/, '')
1636+
.replace(/session_state=[^&\$]*/, '')
1637+
.replace(/^\?&/, '?')
1638+
.replace(/&$/, '')
1639+
.replace(/^\?$/, '') + location.hash;
16371640

16381641
history.replaceState(null, window.name, href);
16391642
}

0 commit comments

Comments
 (0)