|
5 | 5 | <title>Redirecting...</title>
|
6 | 6 | <script>
|
7 | 7 | window.onload = function() {
|
8 |
| - // Lấy đường dẫn hiện tại từ URL |
9 |
| - var path = window.location.pathname; |
| 8 | + // Lấy đường dẫn hiện tại và loại bỏ phần "/easyengine-notes/" |
| 9 | + var path = window.location.pathname.replace(/^\/easyengine-notes\//, "/"); |
10 | 10 |
|
11 |
| - // Kiểm tra nếu đường dẫn bắt đầu bằng `/easyengine-notes/` |
12 |
| - if (path.startsWith("/easyengine-notes/")) { |
13 |
| - // Cắt bỏ đúng phần `/easyengine-notes/` |
14 |
| - path = path.substring(17); // 17 là độ dài của "/easyengine-notes/" |
15 |
| - |
16 |
| - // Đảm bảo đường dẫn không bị trống |
17 |
| - if (path === "") { |
18 |
| - path = "/"; |
19 |
| - } |
| 11 | + // Nếu đường dẫn bị trống sau khi cắt, đặt lại là "/" |
| 12 | + if (path === "") { |
| 13 | + path = "/"; |
20 | 14 | }
|
21 | 15 |
|
22 |
| - // Tạo URL đích chính xác |
| 16 | + // Xây dựng URL mới |
23 | 17 | var newURL = "https://easyengine-notes.pages.dev" + path + window.location.search;
|
24 | 18 |
|
25 |
| - console.log("Redirecting to:", newURL); // Debug kiểm tra |
| 19 | + // Cập nhật lịch sử trình duyệt trước khi redirect |
| 20 | + window.history.replaceState(null, "", newURL); |
26 | 21 |
|
27 |
| - // Chuyển hướng đến URL mới |
| 22 | + // Chuyển hướng |
28 | 23 | window.location.replace(newURL);
|
29 | 24 | };
|
30 | 25 | </script>
|
31 | 26 | </head>
|
32 | 27 | <body>
|
33 | 28 | <p>If you are not redirected, <a id="redirect-link" href="#">click here</a>.</p>
|
34 | 29 | <script>
|
35 |
| - var path = window.location.pathname; |
36 |
| - if (path.startsWith("/easyengine-notes/")) { |
37 |
| - path = path.substring(17); |
38 |
| - if (path === "") { |
39 |
| - path = "/"; |
40 |
| - } |
| 30 | + var path = window.location.pathname.replace(/^\/easyengine-notes\//, "/"); |
| 31 | + if (path === "") { |
| 32 | + path = "/"; |
41 | 33 | }
|
42 | 34 | document.getElementById("redirect-link").href = "https://easyengine-notes.pages.dev" + path + window.location.search;
|
43 | 35 | </script>
|
|
0 commit comments