summaryrefslogtreecommitdiff
path: root/source/github-helpers/get-current-git-ref.ts
diff options
context:
space:
mode:
Diffstat (limited to 'source/github-helpers/get-current-git-ref.ts')
-rw-r--r--source/github-helpers/get-current-git-ref.ts4
1 files changed, 3 insertions, 1 deletions
diff --git a/source/github-helpers/get-current-git-ref.ts b/source/github-helpers/get-current-git-ref.ts
index 71b27222..74abb87a 100644
--- a/source/github-helpers/get-current-git-ref.ts
+++ b/source/github-helpers/get-current-git-ref.ts
@@ -1,6 +1,7 @@
import {isRepoCommitList} from 'github-url-detection';
import select from 'select-dom';
+import {extractCurrentBranchFromBranchPicker} from './index.js';
import {branchSelector} from './selectors.js';
const typesWithGitRef = new Set(['tree', 'blob', 'blame', 'edit', 'commit', 'commits', 'compare']);
@@ -10,7 +11,8 @@ const titleWithGitRef = / at (?<branch>[.\w-/]+)( ยท [\w-]+\/[\w-]+)?$/i;
export default function getCurrentGitRef(): string | undefined {
// Note: This is not in the <head> so it's only available on AJAXed loads.
// It appears on every Code page except `commits` on folders/files
- const refViaPicker = select(branchSelector)?.textContent!.trim();
+ const picker = select(branchSelector);
+ const refViaPicker = picker && extractCurrentBranchFromBranchPicker(picker);
if (refViaPicker) {
return refViaPicker;
}