Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 29 additions & 2 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,19 @@ TEST: addTests('isCompareWikiPage', [
'https://github.com/brookhong/Surfingkeys/wiki/Color-Themes/_compare/8ebb46b1a12d16fc1af442b7df0ca13ca3bb34dc...80e51eeabe69b15a3f23880ecc36f800b71e6c6d',
]);

/**
* @deprecated Use `isHome` and/or `isFeed` instead
*/
export const isDashboard = (url: URL | HTMLAnchorElement | Location = location): boolean => !isGist(url) && /^$|^(orgs\/[^/]+\/)?dashboard(-feed)?(\/|$)/.test(getCleanPathname(url));
TEST: addTests('isDashboard', [
'https://github.com///',
'https://github.com//',
'https://github.com/',
'https://github.com',
'https://github.com/orgs/test/dashboard',
'https://github.com/orgs/refined-github/dashboard',
'https://github.com/dashboard/index/2',
'https://github.com//dashboard',
'https://github.com/dashboard',
'https://github.com/orgs/edit/dashboard',
'https://github.big-corp.com/',
'https://not-github.com/',
'https://my-little-hub.com/',
Expand All @@ -84,6 +86,31 @@ TEST: addTests('isDashboard', [
'https://github.com/dashboard-feed',
]);

export const isHome = (url: URL | HTMLAnchorElement | Location = location): boolean => !isGist(url) && /^$|^dashboard\/?$/.test(getCleanPathname(url));
TEST: addTests('isHome', [
'https://github.com',
'https://github.com//dashboard',
'https://github.com///',
'https://github.com//',
'https://github.com/',
'https://github.com/dashboard',
'https://github.big-corp.com/',
'https://not-github.com/',
'https://my-little-hub.com/',
'https://github.com/?tab=repositories', // Gotcha for `isUserProfileRepoTab`
'https://github.com/?tab=stars', // Gotcha for `isUserProfileStarsTab`
'https://github.com/?tab=followers', // Gotcha for `isUserProfileFollowersTab`
'https://github.com/?tab=following', // Gotcha for `isUserProfileFollowingTab`
'https://github.com/?tab=overview', // Gotcha for `isUserProfileMainTab`
'https://github.com?search=1', // Gotcha for `isRepoTree`
]);

export const isFeed = (url: URL | HTMLAnchorElement | Location = location): boolean => !isGist(url) && /^(feed|orgs\/[^/]+\/dashboard)\/?$/.test(getCleanPathname(url));
TEST: addTests('isFeed', [
'https://github.com/feed',
'https://github.com/orgs/refined-github/dashboard',
]);

export const isEnterprise = (url: URL | HTMLAnchorElement | Location = location): boolean => url.hostname !== 'github.com' && url.hostname !== 'gist.github.com';
TEST: addTests('isEnterprise', [
'https://github.big-corp.com/',
Expand Down
Loading