Skip to content

Commit b4aa32c

Browse files
committed
feat(plugin-redirect): use location.replace to keep history records clean
1 parent 97a54ce commit b4aa32c

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

plugins/tools/plugin-redirect/src/node/generate/getRedirectHTML.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export const getRedirectHTML = (redirectUrl: string): string => `<!doctype html>
88
<title>Redirecting...</title>
99
<script>
1010
const anchor = window.location.hash.substring(1);
11-
location.href = \`${redirectUrl}\${anchor? \`#\${anchor}\`: ""}\`;
11+
window.location.replace(\`${redirectUrl}\${anchor? \`#\${anchor}\`: ""}\`);
1212
</script>
1313
</head>
1414
<body>

plugins/tools/plugin-redirect/src/node/handleRedirectTo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export const handleRedirectTo = ({ frontmatter }: Page, app: App): void => {
1919
{},
2020
`{\
2121
const anchor = window.location.hash.substring(1);\
22-
location.href=\`${redirectUrl}\${anchor? \`#\${anchor}\`: ""}\`;\
22+
window.location.replace(\`${redirectUrl}\${anchor? \`#\${anchor}\`: ""}\`);\
2323
}`,
2424
])
2525
}

0 commit comments

Comments
 (0)