Skip to content

Commit abed969

Browse files
Add isHome & isFeed (#235)
1 parent 7d542d6 commit abed969

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

index.ts

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,19 @@ TEST: addTests('isCompareWikiPage', [
6161
'https://github.com/brookhong/Surfingkeys/wiki/Color-Themes/_compare/8ebb46b1a12d16fc1af442b7df0ca13ca3bb34dc...80e51eeabe69b15a3f23880ecc36f800b71e6c6d',
6262
]);
6363

64+
/**
65+
* @deprecated Use `isHome` and/or `isFeed` instead
66+
*/
6467
export const isDashboard = (url: URL | HTMLAnchorElement | Location = location): boolean => !isGist(url) && /^$|^(orgs\/[^/]+\/)?dashboard(-feed)?(\/|$)/.test(getCleanPathname(url));
6568
TEST: addTests('isDashboard', [
6669
'https://github.com///',
6770
'https://github.com//',
6871
'https://github.com/',
6972
'https://github.com',
70-
'https://github.com/orgs/test/dashboard',
73+
'https://github.com/orgs/refined-github/dashboard',
7174
'https://github.com/dashboard/index/2',
7275
'https://github.com//dashboard',
7376
'https://github.com/dashboard',
74-
'https://github.com/orgs/edit/dashboard',
7577
'https://github.big-corp.com/',
7678
'https://not-github.com/',
7779
'https://my-little-hub.com/',
@@ -84,6 +86,31 @@ TEST: addTests('isDashboard', [
8486
'https://github.com/dashboard-feed',
8587
]);
8688

89+
export const isHome = (url: URL | HTMLAnchorElement | Location = location): boolean => !isGist(url) && /^$|^dashboard\/?$/.test(getCleanPathname(url));
90+
TEST: addTests('isHome', [
91+
'https://github.com',
92+
'https://github.com//dashboard',
93+
'https://github.com///',
94+
'https://github.com//',
95+
'https://github.com/',
96+
'https://github.com/dashboard',
97+
'https://github.big-corp.com/',
98+
'https://not-github.com/',
99+
'https://my-little-hub.com/',
100+
'https://github.com/?tab=repositories', // Gotcha for `isUserProfileRepoTab`
101+
'https://github.com/?tab=stars', // Gotcha for `isUserProfileStarsTab`
102+
'https://github.com/?tab=followers', // Gotcha for `isUserProfileFollowersTab`
103+
'https://github.com/?tab=following', // Gotcha for `isUserProfileFollowingTab`
104+
'https://github.com/?tab=overview', // Gotcha for `isUserProfileMainTab`
105+
'https://github.com?search=1', // Gotcha for `isRepoTree`
106+
]);
107+
108+
export const isFeed = (url: URL | HTMLAnchorElement | Location = location): boolean => !isGist(url) && /^(feed|orgs\/[^/]+\/dashboard)\/?$/.test(getCleanPathname(url));
109+
TEST: addTests('isFeed', [
110+
'https://github.com/feed',
111+
'https://github.com/orgs/refined-github/dashboard',
112+
]);
113+
87114
export const isEnterprise = (url: URL | HTMLAnchorElement | Location = location): boolean => url.hostname !== 'github.com' && url.hostname !== 'gist.github.com';
88115
TEST: addTests('isEnterprise', [
89116
'https://github.big-corp.com/',

0 commit comments

Comments
 (0)