Skip to content

Commit 06fe5cb

Browse files
committed
404: avoid bogus links to non-existing pages
It is theoretically possible that a Git command no longer exists and therefore is no longer documented, either, yet there are links out there pointing to said documentation. Let's try to be somewhat helpful by detecting that situation and directing the reader to the top-level documentation page. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent ea9cccb commit 06fe5cb

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

content/404.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ <h1>That page doesn't exist.</h1>
2525
(async () => {
2626
// fetch the newest version to obtain the list of versions
2727
const result = await fetch(url)
28+
if (result.status < 200 || result.status >= 300) {
29+
el.innerHTML = `The page <code>${command}</code> does not exist in <a href="${
30+
path.substring(0, path.length - command.length - 1)
31+
}">the documentation</a>.`
32+
return
33+
}
2834

2935
const div = document.createElement('div')
3036
div.innerHTML = await result.text()

0 commit comments

Comments
 (0)