Skip to content

Commit 63f5f49

Browse files
authored
Add isRepoHome (#13)
1 parent aa530b9 commit 63f5f49

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

index.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -287,22 +287,27 @@ collect.set('isRepoIssueList', [
287287
'https://github.com/sindresorhus/refined-github/issues?q=is%3Aclosed+sort%3Aupdated-desc',
288288
]);
289289

290-
export const isRepoRoot = (url: URL | Location = location): boolean => /^(tree\/[^/]+)?$/.test(getRepoPath(url)!);
291-
collect.set('isRepoRoot', [
290+
export const isRepoHome = (url: URL | Location = location): boolean => getRepoPath(url) === '';
291+
collect.set('isRepoHome', [
292292
// Some tests are here only as "gotchas" for other tests that may misidentify their pages
293-
'https://github.com/sindresorhus/edit',
294-
'https://github.com/sindresorhus/search',
295293
'https://github.com/sindresorhus/refined-github',
296294
'https://github.com/sindresorhus/refined-github/',
297295
'https://github.com/sindresorhus/notifications/',
296+
'https://github.com/sindresorhus/edit',
297+
'https://github.com/sindresorhus/search',
298+
'https://github.com/sindresorhus/branches',
299+
'https://github.com/sindresorhus/refined-github?files=1',
300+
]);
301+
302+
export const isRepoRoot = (url: URL | Location = location): boolean => /^(tree\/[^/]+)?$/.test(getRepoPath(url)!);
303+
collect.set('isRepoRoot', [
304+
...collect.get('isRepoHome') as string[],
298305
'https://github.com/sindresorhus/refined-github/tree/native-copy-buttons',
299306
'https://github.com/sindresorhus/refined-github/tree/native-copy-buttons/',
300307
'https://github.com/sindresorhus/refined-github/tree/03fa6b8b4d6e68dea9dc9bee1d197ef5d992fbd6',
301308
'https://github.com/sindresorhus/refined-github/tree/03fa6b8b4d6e68dea9dc9bee1d197ef5d992fbd6/',
302309
'https://github.com/sindresorhus/refined-github/tree/57bf4',
303-
'https://github.com/sindresorhus/refined-github?files=1',
304310
'https://github.com/sindresorhus/refined-github/tree/master?files=1',
305-
'https://github.com/sindresorhus/branches',
306311
]);
307312

308313
// This can't use `getRepoPath` to avoid infinite recursion.

0 commit comments

Comments
 (0)