From 36cf21664788f6c2363ca1e2d3776ec858681a70 Mon Sep 17 00:00:00 2001 From: Haralan Dobrev Date: Wed, 23 Mar 2016 00:50:04 +0200 Subject: [PATCH] Use a shorthand variable for ownerName/repoName --- extension/content.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/extension/content.js b/extension/content.js index 4c1c01b..fcc7d7d 100755 --- a/extension/content.js +++ b/extension/content.js @@ -3,9 +3,10 @@ const path = location.pathname; const ownerName = path.split('/')[1]; const repoName = path.split('/')[2]; +const repoUrl = `${ownerName}/${repoName}`; const isDashboard = () => location.pathname === '/' || /(^\/(dashboard))/.test(location.pathname) || /(^\/(orgs)\/)(\w|-)+\/(dashboard)/.test(location.pathname); const isRepo = () => /^\/[^/]+\/[^/]+/.test(location.pathname); -const isRepoRoot = () => location.pathname.replace(/\/$/, '') === `/${ownerName}/${repoName}` || (/\/tree\/$/.test(location.href) && $('.repository-meta-content').length); +const isRepoRoot = () => location.pathname.replace(/\/$/, '') === `/${repoUrl}` || (/\/tree\/$/.test(location.href) && $('.repository-meta-content').length); const isPR = () => /^\/[^/]+\/[^/]+\/pull\/\d+/.test(location.pathname) || /^\/[^/]+\/[^/]+\/pull\/\d+\/commits\/[0-9a-f]{5,40}/.test(location.pathname); const isCommit = () => { if (/^\/[^/]+\/[^/]+\/commit\/[0-9a-f]{5,40}/.test(location.pathname) || /^\/[^/]+\/[^/]+\/pull\/\d+\/commits\/[0-9a-f]{5,40}/.test(location.pathname)) { @@ -137,7 +138,8 @@ function addReleasesTab() { const hasReleases = $releasesTab.length > 0; if (!hasReleases) { - $releasesTab = $(` + + $releasesTab = $(` Releases `); @@ -197,7 +199,7 @@ function addReadmeEditButton() { const readmeContainer = $('#readme'); const readmeName = $('#readme > h3').text().trim(); const currentBranch = $('.file-navigation .select-menu.left button.select-menu-button').attr('title'); - const editHref = `/${ownerName}/${repoName}/edit/${currentBranch}/${readmeName}`; + const editHref = `/${repoUrl}/edit/${currentBranch}/${readmeName}`; const editButtonHtml = `