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,15 +4,23 @@ import { CONTAINER_PARENT_SELECTOR } from "./constants";
44
55const parent = document . querySelector ( CONTAINER_PARENT_SELECTOR ) ;
66
7- const segments = window . location . pathname
8- . split ( "/" )
9- . filter ( ( segment ) => segment !== "" )
10- . map ( ( segment ) => ( {
11- content : segment ,
7+ const segments = [
8+ {
9+ content : "github.com" ,
1210 left : 0 ,
1311 right : 0 ,
1412 hovered : false ,
15- } ) ) ;
13+ } ,
14+ ...window . location . pathname
15+ . split ( "/" )
16+ . filter ( ( segment ) => segment !== "" )
17+ . map ( ( segment ) => ( {
18+ content : segment ,
19+ left : 0 ,
20+ right : 0 ,
21+ hovered : false ,
22+ } ) ) ,
23+ ] ;
1624
1725const div = document . createElement ( "div" ) ;
1826parent . insertAdjacentElement ( "afterend" , div ) ;
@@ -24,9 +32,13 @@ const app = new App({
2432
2533const onPathTested = ( index : number , ok : boolean ) => {
2634 if ( ok ) {
27- app . $set ( { index : index + 1 , status : "loading" } ) ;
35+ // Given index was ok, move to the next segment. Shifted by one extra due to
36+ // `github.com` prefix.
37+ app . $set ( { index : index + 2 , status : "loading" } ) ;
2838 } else {
29- app . $set ( { index, status : "error" } ) ;
39+ // Given index returned 404, mark it as errored. Shifted by one extra due to
40+ // `github.com` prefix.
41+ app . $set ( { index : index + 1 , status : "error" } ) ;
3042 }
3143} ;
3244
You can’t perform that action at this time.
0 commit comments