Skip to content

Commit 49864bd

Browse files
committed
feat: query
1 parent 490fc76 commit 49864bd

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

src/index.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,27 @@ import { createRoot } from "react-dom/client";
44
import { App } from "./App";
55

66
console.log('App starting...');
7+
8+
// Single Page Apps for GitHub Pages
9+
// https://github.com/rafgraph/spa-github-pages
10+
// This script checks to see if a redirect is present in the query string,
11+
// converts it back to the correct url and adds it to the
12+
// browser's history using window.history.replaceState(...),
13+
// which won't cause the browser to attempt to load the new url.
14+
// When the single page app is loaded further down in this file,
15+
// the correct url will be waiting in the browser's history for
16+
// the single page app to route accordingly.
17+
(function(l) {
18+
if (l.search[1] === '/' ) {
19+
var decoded = l.search.slice(1).split('&').map(function(s) {
20+
return s.replace(/~and~/g, '&')
21+
}).join('?');
22+
window.history.replaceState(null, null,
23+
l.pathname.slice(0, -1) + decoded + l.hash
24+
);
25+
}
26+
}(window.location));
27+
728
const container = document.getElementById("root");
829
if (container) {
930
try {

0 commit comments

Comments
 (0)