We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 2ff75ad commit dac31edCopy full SHA for dac31ed
1 file changed
src/.vuepress/components/Redirect.vue
@@ -16,13 +16,25 @@ export default {
16
setup(props) {
17
onMounted(async () => {
18
await nextTick();
19
-
+
20
if (typeof window !== 'undefined') {
21
+ console.log(props.to);
22
+ console.log('window.location', window.location);
23
24
+ // Remove leading/trailing slashes and ensure proper joining
25
+ const joinUrl = (base, path) => {
26
+ const cleanBase = base.replace(/\/$/, '');
27
+ const cleanPath = path.replace(/^\//, '');
28
+ return `${cleanBase}/${cleanPath}`;
29
+ };
30
31
const targetUrl = props.to.endsWith('/') ? props.to : `${props.to}/`;
- window.location.replace(targetUrl);
32
+ const currentUrl = window.location.href;
33
34
+ window.location.replace(joinUrl(currentUrl, targetUrl));
35
}
36
});
37
38
return {};
39
},
40
};
0 commit comments