diff --git a/extension/content.js b/extension/content.js
index 2be994ed9828..af6e4ee85e51 100755
--- a/extension/content.js
+++ b/extension/content.js
@@ -3,7 +3,7 @@
const path = location.pathname;
const isDashboard = path === '/';
const isRepo = /^\/[^/]+\/[^/]+/.test(path);
-const username = path.split('/')[1];
+const ownerName = path.split('/')[1];
const repoName = path.split('/')[2];
const isPR = () => /^\/[^/]+\/[^/]+\/pull\/\d+$/.test(location.pathname);
const isReleases = () => isRepo && /^\/[^/]+\/[^/]+\/(releases|tags)/.test(location.pathname);
@@ -12,18 +12,17 @@ const getUsername = () => $('meta[name="user-login"]').attr('content');
function linkifyBranchRefs() {
$('.commit-ref').each((i, el) => {
const parts = $(el).find('.css-truncate-target');
- let username = parts.eq(0).text();
- let branch = parts.eq(1).text();
+ let branch = parts.eq(parts.length - 1).text();
+ let username = ownerName;
+
+ // if there are two parts the first part is the username
+ if (parts.length > 1) {
+ username = parts.eq(0).text();
+ }
// forked repos can have their name changed; grab it from first commit in PR
const branchRepo = path.includes(username) ? repoName : $('.commit-id').attr('href').split('/')[2];
- // both branches are from the current repo
- if (!branch) {
- branch = username;
- username = getUsername();
- }
-
$(el).wrap(``);
});
}
@@ -34,7 +33,7 @@ function addReleasesTab() {
const hasReleases = $releasesTab.length > 0;
if (!hasReleases) {
- $releasesTab = $(`
+ $releasesTab = $(`
Releases
`);