diff --git a/src/driver/core/SideBar.js b/src/driver/core/SideBar.js index 39f17cc..6f49333 100644 --- a/src/driver/core/SideBar.js +++ b/src/driver/core/SideBar.js @@ -17,7 +17,7 @@ const init = dispatch => async () => { const metaData = URLHelper.parse() if (DOMHelper.isInCodePage()) { detectedBranchName = DOMHelper.getCurrentBranch() // not working well with non-branch blob - || URLHelper.parseBlobSHA() // cannot handle '/' split branch name, should not use when possibly on branch page + || URLHelper.parseSHA() // cannot handle '/' split branch name, should not use when possibly on branch page } metaData.branchName = detectedBranchName || 'master' dispatch(setMetaData, metaData) diff --git a/src/utils/URLHelper.js b/src/utils/URLHelper.js index a5d7e8a..ca00ffa 100644 --- a/src/utils/URLHelper.js +++ b/src/utils/URLHelper.js @@ -18,9 +18,9 @@ function parse() { } } -function parseBlobSHA() { +function parseSHA() { const { type, path } = parse() - return type === 'blob' ? path[0] : false + return (type === 'blob' || type === 'tree') ? path[0] : false } function isInRepoPage() { @@ -81,5 +81,5 @@ export default { isInRepoPage, isInCodePage, parse, - parseBlobSHA, + parseSHA, }