|
5 | 5 | <title>Single Page Apps for GitHub Pages</title>
|
6 | 6 | <script type="text/javascript">
|
7 | 7 | // Single Page Apps for GitHub Pages
|
8 |
| - // https://github.com/rafrex/spa-github-pages |
9 |
| - // Copyright (c) 2016 Rafael Pedicini, licensed under the MIT License |
10 |
| - // ---------------------------------------------------------------------- |
| 8 | + // MIT License |
| 9 | + // https://github.com/rafgraph/spa-github-pages |
11 | 10 | // This script takes the current url and converts the path and query
|
12 | 11 | // string into just a query string, and then redirects the browser
|
13 | 12 | // to the new url with only a query string and hash fragment,
|
14 |
| - // e.g. http://www.foo.tld/one/two?a=b&c=d#qwe, becomes |
15 |
| - // http://www.foo.tld/?p=/one/two&q=a=b~and~c=d#qwe |
| 13 | + // e.g. https://www.foo.tld/one/two?a=b&c=d#qwe, becomes |
| 14 | + // https://www.foo.tld/?/one/two&a=b~and~c=d#qwe |
16 | 15 | // Note: this 404.html file must be at least 512 bytes for it to work
|
17 | 16 | // with Internet Explorer (it is currently > 512 bytes)
|
| 17 | + |
18 | 18 | // If you're creating a Project Pages site and NOT using a custom domain,
|
19 |
| - // then set segmentCount to 1 (enterprise users may need to set it to > 1). |
| 19 | + // then set pathSegmentsToKeep to 1 (enterprise users may need to set it to > 1). |
20 | 20 | // This way the code will only replace the route part of the path, and not
|
21 | 21 | // the real directory in which the app resides, for example:
|
22 | 22 | // https://username.github.io/repo-name/one/two?a=b&c=d#qwe becomes
|
23 |
| - // https://username.github.io/repo-name/?p=/one/two&q=a=b~and~c=d#qwe |
24 |
| - // Otherwise, leave segmentCount as 0. |
25 |
| - var segmentCount = 1; |
| 23 | + // https://username.github.io/repo-name/?/one/two&a=b~and~c=d#qwe |
| 24 | + // Otherwise, leave pathSegmentsToKeep as 0. |
| 25 | + var pathSegmentsToKeep = 0; |
| 26 | + |
26 | 27 | var l = window.location;
|
27 | 28 | l.replace(
|
28 | 29 | l.protocol + '//' + l.hostname + (l.port ? ':' + l.port : '') +
|
29 |
| - l.pathname.split('/').slice(0, 1 + segmentCount).join('/') + '/?p=/' + |
30 |
| - l.pathname.slice(1).split('/').slice(segmentCount).join('/').replace(/&/g, '~and~') + |
31 |
| - (l.search ? '&q=' + l.search.slice(1).replace(/&/g, '~and~') : '') + |
| 30 | + l.pathname.split('/').slice(0, 1 + pathSegmentsToKeep).join('/') + '/?/' + |
| 31 | + l.pathname.slice(1).split('/').slice(pathSegmentsToKeep).join('/').replace(/&/g, '~and~') + |
| 32 | + (l.search ? '&' + l.search.slice(1).replace(/&/g, '~and~') : '') + |
32 | 33 | l.hash
|
33 | 34 | );
|
| 35 | + |
34 | 36 | </script>
|
35 | 37 | </head>
|
36 | 38 | <body>
|
|
0 commit comments