|
| 1 | + |
| 2 | +<!DOCTYPE html> |
| 3 | +<html> |
| 4 | + <head> |
| 5 | + <meta charset="utf-8"> |
| 6 | + <title>Single Page Apps for GitHub Pages</title> |
| 7 | + <script type="text/javascript"> |
| 8 | + // Single Page Apps for GitHub Pages |
| 9 | + // MIT License |
| 10 | + // https://github.com/rafgraph/spa-github-pages |
| 11 | + // This script checks to see if a redirect is present in the query string, |
| 12 | + // converts it back into the correct url and adds it to the |
| 13 | + // browser's history using window.history.replaceState(...), |
| 14 | + // which won't cause the browser to attempt to load the new url. |
| 15 | + // When the single page app is loaded further down in this file, |
| 16 | + // the correct url will be waiting in the browser's history for |
| 17 | + // the single page app to route accordingly. |
| 18 | + (function(l) { |
| 19 | + if (l.search[1] === '/' ) { |
| 20 | + var decoded = l.search.slice(1).split('&').map(function(s) { |
| 21 | + return s.replace(/~and~/g, '&') |
| 22 | + }).join('?'); |
| 23 | + window.history.replaceState(null, null, |
| 24 | + l.pathname.slice(0, -1) + decoded + l.hash |
| 25 | + ); |
| 26 | + } |
| 27 | + }(window.location)) |
| 28 | + </script> |
| 29 | + </head> |
| 30 | + <body> |
| 31 | + <script type="text/javascript"> |
| 32 | + // Immediately redirect to index.html with the path as a query parameter |
| 33 | + var pathSegmentsToKeep = 0; |
| 34 | + var l = window.location; |
| 35 | + l.replace( |
| 36 | + l.protocol + '//' + l.hostname + (l.port ? ':' + l.port : '') + |
| 37 | + l.pathname.split('/').slice(0, 1 + pathSegmentsToKeep).join('/') + '/?/' + |
| 38 | + l.pathname.slice(1).split('/').slice(pathSegmentsToKeep).join('/').replace(/&/g, '~and~') + |
| 39 | + (l.search ? '&' + l.search.slice(1).replace(/&/g, '~and~') : '') + |
| 40 | + l.hash |
| 41 | + ); |
| 42 | + </script> |
| 43 | + </body> |
| 44 | +</html> |
0 commit comments