mirror of
https://github.com/EnixCoda/Gitako.git
synced 2026-03-11 08:54:44 +00:00
39 lines
755 B
JavaScript
39 lines
755 B
JavaScript
function parse() {
|
|
const { pathname } = window.location
|
|
const [
|
|
,
|
|
// ignore content before the first '/'
|
|
userName,
|
|
repoName,
|
|
type,
|
|
branchName,
|
|
] = pathname.split('/')
|
|
return {
|
|
userName,
|
|
repoName,
|
|
type,
|
|
branchName,
|
|
}
|
|
}
|
|
|
|
const RESERVED_NAME = ['blog']
|
|
function isInCodePage() {
|
|
const { userName, repoName, type, branchName } = parse()
|
|
return !!(
|
|
userName &&
|
|
!RESERVED_NAME.find(_ => _ === userName) &&
|
|
repoName &&
|
|
(!type || type === 'tree' || type === 'blob') &&
|
|
((type && branchName) || !(type || branchName))
|
|
)
|
|
}
|
|
|
|
function detectShouldShow(metaData) {
|
|
return isInCodePage() && (!metaData || metaData.repoName)
|
|
}
|
|
|
|
export default {
|
|
detectShouldShow,
|
|
isInCodePage,
|
|
parse,
|
|
}
|