summaryrefslogtreecommitdiff
path: root/source/features/link-to-file-in-file-history.tsx
diff options
context:
space:
mode:
authorGravatar yakov116 <16872793+yakov116@users.noreply.github.com> 2020-05-25 06:08:51 -0400
committerGravatar GitHub <noreply@github.com> 2020-05-25 12:08:51 +0200
commitd7e6837cf00eb7bc478852b2f80c3411c778a621 (patch)
treeb5063950b1ca9031d90cdfb372dcd1e0f9f87f7a /source/features/link-to-file-in-file-history.tsx
parentca781c410d2e72540e06065b78d9e1cc9119f1ca (diff)
downloadrefined-github-d7e6837cf00eb7bc478852b2f80c3411c778a621.tar.gz
refined-github-d7e6837cf00eb7bc478852b2f80c3411c778a621.tar.zst
refined-github-d7e6837cf00eb7bc478852b2f80c3411c778a621.zip
Ensure features work on branches/tags with slashes /2 (#3131)
Diffstat (limited to 'source/features/link-to-file-in-file-history.tsx')
-rw-r--r--source/features/link-to-file-in-file-history.tsx11
1 files changed, 4 insertions, 7 deletions
diff --git a/source/features/link-to-file-in-file-history.tsx b/source/features/link-to-file-in-file-history.tsx
index 3e35e5f2..c2322fb3 100644
--- a/source/features/link-to-file-in-file-history.tsx
+++ b/source/features/link-to-file-in-file-history.tsx
@@ -4,23 +4,20 @@ import FileIcon from 'octicon/file.svg';
import * as pageDetect from 'github-url-detection';
import features from '.';
+import parseRoute from '../github-helpers/parse-route';
import {groupSiblings} from '../github-helpers/group-buttons';
function init(): void | false {
- const breadcrumb = select('.breadcrumb');
- if (!breadcrumb) {
- // Probably looking at the base /commits/<branch> page, not a subfolder or file.
+ const {filePath} = parseRoute(location.pathname);
+ if (!filePath) {
return false;
}
- // Extract the file path from the breadcrumb. Aware of branch names that contain slashes
- const path = breadcrumb.textContent!.trim().replace(/^History for [^/]+/, '');
-
for (const rootLink of select.all<HTMLAnchorElement>('[aria-label="Browse the repository at this point in the history"]')) {
// `rootLink.pathname` points to /tree/ but GitHub automatically redirects to /blob/ when the path is of a file
rootLink.before(
<a
- href={rootLink.pathname + path}
+ href={rootLink.pathname + '/' + filePath}
className="btn btn-outline tooltipped tooltipped-sw"
aria-label="See object at this point in the history"
>