Skip to content

Commit

Permalink
user-repo-branch: Ignore ${user}/${repo}/edit/ URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
josephfrazier committed Apr 11, 2017
1 parent 1827225 commit f1fba1f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/user-repo-branch.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default function userRepoBranch (href) {
const branch = githubInfo.branch.split('/')[0]

// skip false positives like issue/pull urls
if (!href.includes(branch)) {
if (!href.includes(branch) || isIssueUrl(href, user, repo)) {
if (branch !== 'master' || isIssueUrl(href, user, repo)) {
return { user, repo }
}
Expand All @@ -39,6 +39,7 @@ function isIssueUrl (href, user, repo) {
'commit/',
'search?',
'milestones',
'edit/',
'releases'
].some(component => href.includes(`${user}/${repo}/${component}`))
}
Expand Down
7 changes: 7 additions & 0 deletions test/user-repo-branch.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,10 @@ test('https://github.com/mozilla/web-ext/issues?utf8=%E2%9C%93&q=is%3Aclosed%20l
repo: 'web-ext'
})
})

test('https://github.com/x0rz/EQGRP/edit/master/README.md', (t) => {
t.deepEqual(userRepoBranch('https://github.com/x0rz/EQGRP/edit/master/README.md'), {
user: 'x0rz',
repo: 'EQGRP'
})
})

0 comments on commit f1fba1f

Please sign in to comment.