mirror of
https://github.com/EnixCoda/Gitako.git
synced 2026-03-11 08:54:44 +00:00
fix: prevent loading at non-project page
This commit is contained in:
parent
2a5e517fab
commit
07163774e7
2 changed files with 14 additions and 3 deletions
|
|
@ -6,6 +6,7 @@ import keyHelper from '../../utils/keyHelper'
|
|||
|
||||
const init = dispatch => async () => {
|
||||
try {
|
||||
if (!URLHelper.isInRepoPage()) return
|
||||
let nothingWentWrong = true
|
||||
const metaData = URLHelper.parse()
|
||||
dispatch(setMetaData, metaData)
|
||||
|
|
|
|||
|
|
@ -33,12 +33,21 @@ const TYPES = {
|
|||
// known but not related types: issues, pulls, wiki, insight,
|
||||
// TODO: record more types
|
||||
}
|
||||
function isInCodePage(metaData = {}) {
|
||||
const { userName, repoName, type, branchName } = { ...parseRaw(), ...metaData }
|
||||
|
||||
function isInRepoPage(metaData) {
|
||||
const { userName, repoName } = metaData || parseRaw()
|
||||
return Boolean(
|
||||
userName &&
|
||||
!RESERVED_NAME.find(_ => _ === userName) &&
|
||||
repoName &&
|
||||
repoName
|
||||
)
|
||||
}
|
||||
|
||||
function isInCodePage(metaData = {}) {
|
||||
const mergedRepo = { ...parseRaw(), ...metaData }
|
||||
const { type, branchName } = mergedRepo
|
||||
return Boolean(
|
||||
isInRepoPage(mergedRepo) &&
|
||||
(!type || type === TYPES.TREE || type === TYPES.BLOB) &&
|
||||
type !== TYPES.COMMIT &&
|
||||
(branchName || (!type && !branchName))
|
||||
|
|
@ -52,6 +61,7 @@ function getCurrentPath(decode = false) {
|
|||
|
||||
export default {
|
||||
getCurrentPath,
|
||||
isInRepoPage,
|
||||
isInCodePage,
|
||||
parse,
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue