summaryrefslogtreecommitdiff
path: root/source/features/enable-file-links-in-compare-view.tsx
diff options
context:
space:
mode:
authorGravatar Federico Brigante <me@fregante.com> 2023-04-26 02:40:38 +0800
committerGravatar GitHub <noreply@github.com> 2023-04-25 18:40:38 +0000
commit4e5358b64f015e601560d805e0ae0f47b0c808bf (patch)
treea5c6cc483513bd8818c84ec856e938880d6eadb5 /source/features/enable-file-links-in-compare-view.tsx
parentd3c0cc60347761410d23359ad285ba11a672c714 (diff)
downloadrefined-github-4e5358b64f015e601560d805e0ae0f47b0c808bf.tar.gz
refined-github-4e5358b64f015e601560d805e0ae0f47b0c808bf.tar.zst
refined-github-4e5358b64f015e601560d805e0ae0f47b0c808bf.zip
Use `getBranches` in more places, cleanup and test (#6556)
Diffstat (limited to 'source/features/enable-file-links-in-compare-view.tsx')
-rw-r--r--source/features/enable-file-links-in-compare-view.tsx5
1 files changed, 3 insertions, 2 deletions
diff --git a/source/features/enable-file-links-in-compare-view.tsx b/source/features/enable-file-links-in-compare-view.tsx
index e64fe86d..e59dc4fb 100644
--- a/source/features/enable-file-links-in-compare-view.tsx
+++ b/source/features/enable-file-links-in-compare-view.tsx
@@ -6,16 +6,17 @@ import delegate, {DelegateEvent} from 'delegate-it';
import features from '../feature-manager';
import GitHubURL from '../github-helpers/github-url';
+import {getBranches} from '../github-helpers/pr-branches';
/** Rebuilds the "View file" link because it points to the base repo and to the commit, instead of the head repo and its branch */
function handlePRMenuOpening({delegateTarget: dropdown}: DelegateEvent): void {
dropdown.classList.add('rgh-actionable-link'); // Mark this as processed
- const [nameWithOwner, headBranch] = select('.head-ref')!.title.split(':');
+ const {nameWithOwner, branch} = getBranches().head;
const filePath = dropdown.closest('[data-path]')!.getAttribute('data-path')!;
select('a[data-ga-click^="View file"]', dropdown)!
- .pathname = [nameWithOwner, 'blob', headBranch, filePath].join('/'); // Do not replace with `GitHubURL` #3152 #3111 #2595
+ .pathname = [nameWithOwner, 'blob', branch, filePath].join('/'); // Do not replace with `GitHubURL` #3152 #3111 #2595
}
function handleCompareMenuOpening({delegateTarget: dropdown}: DelegateEvent): void {