|
3 | 3 | <head> |
4 | 4 | <meta charset="UTF-8" /> |
5 | 5 | <meta name="viewport" content="width=device-width, initial-scale=1.0" /> |
6 | | - <title>Loading...</title> |
| 6 | + <title>Redirecting...</title> |
7 | 7 | <script> |
8 | | - // Surge serves 404.html for unknown routes unless a 200 fallback is provided. |
9 | | - // Instead of mutating the URL (which produced /?/… redirects), load the main |
10 | | - // SPA shell in-place so React Router can hydrate the correct route. |
11 | | - fetch('/index.html', { credentials: 'same-origin' }) |
12 | | - .then((response) => response.text()) |
13 | | - .then((html) => { |
14 | | - document.open(); |
15 | | - document.write(html); |
16 | | - document.close(); |
17 | | - }) |
18 | | - .catch(() => { |
19 | | - window.location.replace('/'); |
20 | | - }); |
| 8 | + // SPA redirect for GitHub Pages: move path into query so index.html can restore it |
| 9 | + (function () { |
| 10 | + var l = window.location; |
| 11 | + // derive base path like /owner/repo or /repo depending on hosting |
| 12 | + var parts = l.pathname.split('/').filter(Boolean); |
| 13 | + // assume repo is the first path segment when hosted on browserstack.github.io |
| 14 | + var repoIndex = parts.indexOf('test-selection-demo-app-browserstack'); |
| 15 | + var base = '/test-selection-demo-app-browserstack/'; |
| 16 | + // If repo not found, fall back to root |
| 17 | + if (repoIndex === -1) { |
| 18 | + base = '/'; |
| 19 | + } |
| 20 | + var newPath = base + '?/' + l.pathname.slice(base.length).replace(/&/g, '~and~') + (l.search ? '&' + l.search.slice(1).replace(/&/g, '~and~') : '') + l.hash; |
| 21 | + l.replace(l.protocol + '//' + l.host + newPath); |
| 22 | + })(); |
21 | 23 | </script> |
22 | 24 | </head> |
23 | 25 | <body> |
24 | | - <p>Loading the application…</p> |
| 26 | + <p>Redirecting to the app...</p> |
25 | 27 | </body> |
26 | 28 | </html> |
0 commit comments