summaryrefslogtreecommitdiff
path: root/source/features/useful-not-found-page.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'source/features/useful-not-found-page.tsx')
-rw-r--r--source/features/useful-not-found-page.tsx31
1 files changed, 17 insertions, 14 deletions
diff --git a/source/features/useful-not-found-page.tsx b/source/features/useful-not-found-page.tsx
index bebbe1e4..fddc3917 100644
--- a/source/features/useful-not-found-page.tsx
+++ b/source/features/useful-not-found-page.tsx
@@ -143,18 +143,9 @@ async function showAlternateLink(): Promise<void> {
);
}
-function init(): false | void {
- const parts = parseCurrentURL();
- if (parts.length < 2) {
- return false;
- }
-
- void showMissingPart();
-
- if (['tree', 'blob', 'edit'].includes(parts[2])) {
- void showDefaultBranchLink();
- void showAlternateLink();
- }
+function init(): void {
+ void showDefaultBranchLink();
+ void showAlternateLink();
}
async function initPRCommit(): Promise<void | false> {
@@ -169,10 +160,22 @@ async function initPRCommit(): Promise<void | false> {
);
}
-void features.add(__filebasename, {
- include: [
+void features.add(__filebasename, {
+ asLongAs: [
+ pageDetect.is404,
+ () => parseCurrentURL().length > 1,
+ ],
+ init: showMissingPart,
+},
+{
+ asLongAs: [
pageDetect.is404,
],
+ include: [
+ pageDetect.isSingleFile,
+ pageDetect.isRepoTree,
+ pageDetect.isEditingFile,
+ ],
init: onetime(init),
}, {
include: [