File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4,6 +4,27 @@ import { createRoot } from "react-dom/client";
44import { App } from "./App" ;
55
66console . 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 ( / ~ a n d ~ / g, '&' )
21+ } ) . join ( '?' ) ;
22+ window . history . replaceState ( null , null ,
23+ l . pathname . slice ( 0 , - 1 ) + decoded + l . hash
24+ ) ;
25+ }
26+ } ( window . location ) ) ;
27+
728const container = document . getElementById ( "root" ) ;
829if ( container ) {
930 try {
You can’t perform that action at this time.
0 commit comments