Skip to content

Commit a60b3b2

Browse files
authored
fix(version switcher): 404 pages (#4755)
* refactor: let's not replace the current page anymore users cannot go back in history, which is very annoying. * fix: incorrect URL part
1 parent 0279666 commit a60b3b2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

showcases/patternhub/components/version-switcher/version-switcher.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,11 @@ const VersionSwitcher = () => {
101101
}, []);
102102

103103
const handleChange = (branch: string) => {
104-
const lastPath = router.asPath;
104+
const lastPath = router.asPath.replace('core-web/version/latest/', ''); // We need to handle the version/latest differently, as this is a redirect we're generating server-side, and it's not a regular route
105105
const isTag =
106106
(branch.split('.').length === 3 && branch.startsWith('v')) ||
107107
branch === 'latest';
108-
globalThis.location.replace(
108+
globalThis.location.assign(
109109
DOMPurify.sanitize(
110110
`https://${owner}.github.io/${repo}${isTag ? '/version' : '/review'}/${branch}${lastPath}`
111111
)

0 commit comments

Comments
 (0)