summaryrefslogtreecommitdiff
path: root/source/features/enable-file-links-in-compare-view.tsx
diff options
context:
space:
mode:
authorGravatar Federico <me@fregante.com> 2021-04-03 22:09:40 +0700
committerGravatar GitHub <noreply@github.com> 2021-04-03 22:09:40 +0700
commitf41d7f230463554e8f9ea163d0dad9a004bc6e2f (patch)
tree134eecd0dbebb4778f002646f69ac0f6993c1547 /source/features/enable-file-links-in-compare-view.tsx
parent936eedbb0bb37a30fc44a2cc7e5f3af31f24a3fc (diff)
downloadrefined-github-f41d7f230463554e8f9ea163d0dad9a004bc6e2f.tar.gz
refined-github-f41d7f230463554e8f9ea163d0dad9a004bc6e2f.tar.zst
refined-github-f41d7f230463554e8f9ea163d0dad9a004bc6e2f.zip
Improve branch getter function (#4193)
Diffstat (limited to 'source/features/enable-file-links-in-compare-view.tsx')
-rw-r--r--source/features/enable-file-links-in-compare-view.tsx7
1 files changed, 4 insertions, 3 deletions
diff --git a/source/features/enable-file-links-in-compare-view.tsx b/source/features/enable-file-links-in-compare-view.tsx
index 1b374f2b..2bf1edb8 100644
--- a/source/features/enable-file-links-in-compare-view.tsx
+++ b/source/features/enable-file-links-in-compare-view.tsx
@@ -6,15 +6,16 @@ import * as pageDetect from 'github-url-detection';
import features from '.';
import GitHubURL from '../github-helpers/github-url';
-import {getCurrentBranch, getPRHeadRepo} from '../github-helpers';
/** 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}: delegate.Event): void {
dropdown.classList.add('rgh-actionable-link'); // Mark this as processed
+
+ const [nameWithOwner, headBranch] = select('.head-ref')!.title.split(':');
const filePath = dropdown.closest('[data-path]')!.getAttribute('data-path')!;
- const viewFile = select('a[data-ga-click^="View file"]', dropdown)!;
- viewFile.pathname = [getPRHeadRepo()!.nameWithOwner, 'blob', getCurrentBranch()!, filePath].join('/'); // Do not replace with `GitHubURL` #3152 #3111 #2595
+ select('a[data-ga-click^="View file"]', dropdown)!
+ .pathname = [nameWithOwner, 'blob', headBranch, filePath].join('/'); // Do not replace with `GitHubURL` #3152 #3111 #2595
}
function handleCompareMenuOpening({delegateTarget: dropdown}: delegate.Event): void {