summaryrefslogtreecommitdiff
path: root/source/github-helpers
diff options
context:
space:
mode:
authorGravatar 오지환 (Cooper) <cooper@chequer.io> 2023-08-24 20:41:06 +0900
committerGravatar GitHub <noreply@github.com> 2023-08-24 18:41:06 +0700
commitc23f33b34159b91ab1ff3987515e03e9bac0948a (patch)
treed0f57736d24b11fd0eec606d4a83589fe1cdf14d /source/github-helpers
parenta845070fdd9fbde4aa63ecce7882b33335423cc4 (diff)
downloadrefined-github-c23f33b34159b91ab1ff3987515e03e9bac0948a.tar.gz
refined-github-c23f33b34159b91ab1ff3987515e03e9bac0948a.tar.zst
refined-github-c23f33b34159b91ab1ff3987515e03e9bac0948a.zip
Improve support of New Repository Overview (#6837)
Diffstat (limited to 'source/github-helpers')
-rw-r--r--source/github-helpers/get-default-branch.ts10
1 files changed, 8 insertions, 2 deletions
diff --git a/source/github-helpers/get-default-branch.ts b/source/github-helpers/get-default-branch.ts
index f5e0c5db..5681325b 100644
--- a/source/github-helpers/get-default-branch.ts
+++ b/source/github-helpers/get-default-branch.ts
@@ -11,13 +11,19 @@ const isCurrentRepo = ({nameWithOwner}: RepositoryInfo): boolean => Boolean(getR
// Do not make this function complicated. We're only optimizing for the repo root.
async function fromDOM(): Promise<string | undefined> {
if (!['', 'commits'].includes(getRepo()!.path)) {
- return undefined;
+ return;
}
// We're on the default branch, so we can extract it from the current page. This exclusively happens on the exact pages:
// /user/repo
// /user/repo/commits (without further path)
- return extractCurrentBranchFromBranchPicker((await elementReady(branchSelector))!);
+ const element = await elementReady(branchSelector);
+
+ if (!element) {
+ return;
+ }
+
+ return extractCurrentBranchFromBranchPicker(element);
}
async function fromAPI(repository: RepositoryInfo): Promise<string> {