|
8 | 8 | (function () { |
9 | 9 | var l = window.location; |
10 | 10 | var pathname = l.pathname; |
| 11 | + var redirectKey = "euphoric_redirect_done"; |
11 | 12 |
|
12 | | - // If we're already on index.html, don't redirect (let React Router handle it) |
13 | | - if (pathname === "/euphoric/index.html" || pathname === "/euphoric/") { |
| 13 | + // Check if we've already redirected (prevent loops) |
| 14 | + if (sessionStorage.getItem(redirectKey)) { |
| 15 | + sessionStorage.removeItem(redirectKey); |
| 16 | + return; // Already redirected, let React Router handle it |
| 17 | + } |
| 18 | + |
| 19 | + // If we're already on index.html or base path, don't redirect |
| 20 | + if ( |
| 21 | + pathname === "/euphoric/index.html" || |
| 22 | + pathname === "/euphoric/" || |
| 23 | + pathname === "/euphoric" |
| 24 | + ) { |
14 | 25 | return; |
15 | 26 | } |
16 | 27 |
|
17 | 28 | // If path contains index.html multiple times, we're in a loop - stop |
18 | 29 | var indexHtmlCount = (pathname.match(/index\.html/g) || []).length; |
19 | 30 | if (indexHtmlCount > 1) { |
20 | | - // Force redirect to base path |
| 31 | + sessionStorage.setItem(redirectKey, "true"); |
21 | 32 | l.replace("/euphoric/"); |
22 | 33 | return; |
23 | 34 | } |
|
26 | 37 | var route = pathname |
27 | 38 | .replace(/^\/euphoric\/?/, "") |
28 | 39 | .replace(/^index\.html\/?/, ""); |
29 | | - |
30 | | - // Remove any duplicate euphoric/index.html patterns |
31 | 40 | route = route.replace(/euphoric\/index\.html\/?/g, ""); |
32 | | - |
33 | | - // Clean up the route |
34 | 41 | route = route.replace(/\/+/g, "/").replace(/^\//, ""); |
35 | 42 |
|
36 | | - // Redirect to index.html - React Router with basename will handle the route |
37 | | - // The route is preserved in the URL path, React Router will match it |
38 | | - var redirectUrl = "/euphoric/index.html" + (route ? "/" + route : "") + l.search + l.hash; |
39 | | - |
40 | | - // Only redirect if we're not already there and not in a loop |
41 | | - if (pathname !== redirectUrl && !pathname.includes("/index.html")) { |
42 | | - l.replace(redirectUrl); |
43 | | - } |
| 43 | + // Set flag and redirect to base path |
| 44 | + // React Router with basename="/euphoric" will handle the route from the original URL |
| 45 | + sessionStorage.setItem(redirectKey, "true"); |
| 46 | + var targetPath = "/euphoric" + (route ? "/" + route : ""); |
| 47 | + l.replace(targetPath + l.search + l.hash); |
44 | 48 | })(); |
45 | 49 | </script> |
46 | 50 | </head> |
|
0 commit comments