Improve error message & refactor reserved names
This commit is contained in:
parent
008ed6bc6c
commit
3f26d4c65e
|
@ -2,8 +2,22 @@
|
|||
const PREFIX = 'octotree'
|
||||
, TOKEN = 'octotree.github_access_token'
|
||||
, SHOWN = 'octotree.shown'
|
||||
// ugly, I know, can it be improved?
|
||||
, REGEXP = /([^\/]+)\/([^\/]+)(?:\/([^\/]+))?/
|
||||
, REGEXP = /([^\/]+)\/([^\/]+)(?:\/([^\/]+))?/ // (username)/(reponame)/(subpart)
|
||||
, RESERVED_USER_NAMES = [
|
||||
'settings',
|
||||
'organizations',
|
||||
'site',
|
||||
'blog',
|
||||
'about',
|
||||
'orgs',
|
||||
'styleguide',
|
||||
'showcases',
|
||||
'trending',
|
||||
'stars',
|
||||
'dashboard',
|
||||
'notifications'
|
||||
]
|
||||
, RESERVED_REPO_NAMES = ['followers', 'following']
|
||||
|
||||
var $html = $('html')
|
||||
, $sidebar = $('<nav class="octotree_sidebar">' +
|
||||
|
@ -47,26 +61,9 @@
|
|||
function getRepoFromPath() {
|
||||
var match = location.pathname.match(REGEXP)
|
||||
if (!match) return false
|
||||
|
||||
// must not be a reserved `username`
|
||||
var RESERVED_USERNAMES = [
|
||||
'settings',
|
||||
'organizations',
|
||||
'site',
|
||||
'blog',
|
||||
'about',
|
||||
'orgs',
|
||||
'styleguide',
|
||||
'showcases',
|
||||
'trending',
|
||||
'stars',
|
||||
'dashboard',
|
||||
'notifications'
|
||||
];
|
||||
var RESERVED_REPONAMES = ['followers', 'following'];
|
||||
|
||||
if (~RESERVED_USERNAMES.indexOf(match[1])) return false
|
||||
if (~RESERVED_REPONAMES.indexOf(match[2])) return false
|
||||
if (~RESERVED_USER_NAMES.indexOf(match[1])) return false
|
||||
if (~RESERVED_REPO_NAMES.indexOf(match[2])) return false
|
||||
|
||||
// TODO: the intention is to hide the sidebar when users navigate to non-code areas (e.g. Issues, Pulls)
|
||||
// and show it again when users navigate back to the code area
|
||||
|
@ -131,7 +128,7 @@
|
|||
|
||||
if (err.error === 401) {
|
||||
header = 'Invalid token!'
|
||||
message = 'The provided token is invalid. Please enter another one.'
|
||||
message = 'The provided token is invalid. Follow <a href="https://github.com/settings/tokens/new" target="_blank">this link</a> to create a new token and paste it in the textbox below.'
|
||||
}
|
||||
|
||||
else if (err.error === 404) {
|
||||
|
|
Loading…
Reference in New Issue