Skip to content

Commit

Permalink
fix(clerk-js): Replace state when merging fragment into url
Browse files Browse the repository at this point in the history
  • Loading branch information
desiprisg committed Jun 6, 2023
1 parent 00d8d74 commit 18638b8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/clerk-js/src/ui/router/PathRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ export const PathRouter = ({ basePath, preservedParams, children }: PathRouterPr
const convertHashToPath = async () => {
if (hasUrlInFragment(window.location.hash)) {
const url = mergeFragmentIntoUrl(new URL(window.location.href));
await internalNavigate(url.href);
window.history.replaceState(window.history.state, '', url.href);
await internalNavigate(url.href); // make this navigation as well since replaceState is asynchronous
setStripped(true);
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ describe('PathRouter', () => {
beforeAll(() => {
// @ts-ignore
delete window.location;
history.replaceState = jest.fn();
});

afterAll(() => {
Expand Down

0 comments on commit 18638b8

Please sign in to comment.