Skip to content

Commit 2638edd

Browse files
committed
fix github.com prefix was missing
Fixes #9
1 parent 11318a3 commit 2638edd

1 file changed

Lines changed: 20 additions & 8 deletions

File tree

src/index.ts

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,23 @@ import { CONTAINER_PARENT_SELECTOR } from "./constants";
44

55
const 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

1725
const div = document.createElement("div");
1826
parent.insertAdjacentElement("afterend", div);
@@ -24,9 +32,13 @@ const app = new App({
2432

2533
const 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

0 commit comments

Comments
 (0)