Skip to content
Open
Show file tree
Hide file tree
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
85 changes: 4 additions & 81 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"xo": "xo"
},
"dependencies": {
"github-reserved-names": "^2.1.1"
"github-reserved-names": "^2.1.2"
},
"devDependencies": {
"@sindresorhus/tsconfig": "^8.1.0",
Expand Down