Skip to content

Commit 4255861

Browse files
changes
1 parent f9a97ac commit 4255861

1 file changed

Lines changed: 18 additions & 15 deletions

File tree

index.ts

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -183,19 +183,28 @@ TEST: addTests('isGist', [
183183
'https://gist.my-little-hub.com/in-fragrante',
184184
]);
185185

186-
export const isGlobalIssueOrPRList = (url: URL | HTMLAnchorElement | Location = location): boolean => ['issues', 'pulls'].includes(url.pathname.split('/', 2)[1]!);
187-
TEST: addTests('isGlobalIssueOrPRList', [
186+
export const isGlobalIssueList = (url: URL | HTMLAnchorElement | Location = location): boolean => getCleanPathname(url) === 'issues';
187+
TEST: addTests('isGlobalPRList', [
188188
'https://github.com/issues',
189-
'https://github.com/issues?q=is%3Apr+is%3Aopen',
190189
'https://github.com/issues/assigned',
191190
'https://github.com/issues/mentioned',
191+
'https://github.com/issues?q=is%3Apr+is%3Aopen',
192+
'https://github.com//issues/',
193+
]);
194+
195+
export const isGlobalPRList = (url: URL | HTMLAnchorElement | Location = location): boolean => getCleanPathname(url) === 'pulls';
196+
TEST: addTests('isGlobalPRList', [
192197
'https://github.com/pulls',
193-
'https://github.com/pulls?q=issues',
194198
'https://github.com/pulls/assigned',
195199
'https://github.com/pulls/mentioned',
196200
'https://github.com/pulls/review-requested',
201+
'https://github.com/pulls?q=issues',
202+
'https://github.com//pulls/',
197203
]);
198204

205+
export const isGlobalIssueOrPRList = (url: URL | HTMLAnchorElement | Location = location): boolean => isGlobalIssueList(url) || isGlobalPRList(url);
206+
TEST: addTests('isGlobalIssueOrPRList', combinedTestOnly);
207+
199208
export const isGlobalSearchResults = (url: URL | HTMLAnchorElement | Location = location): boolean => url.pathname === '/search' && new URLSearchParams(url.search).get('q') !== null;
200209
TEST: addTests('isGlobalSearchResults', [
201210
'https://github.com/search?q=refined-github&ref=opensearch',
@@ -318,16 +327,8 @@ TEST: addTests('isPRConflicts', [
318327
]);
319328

320329
/** Any `isIssueOrPRList` can display both issues and PRs, prefer that detection. `isPRList` only exists because this page has PR-specific filters like the "Reviews" dropdown */
321-
export const isPRList = (url: URL | HTMLAnchorElement | Location = location): boolean => url.pathname.startsWith('/pulls') || isRepoPRList(url);
322-
TEST: addTests('isPRList', [
323-
'https://github.com/pulls',
324-
'https://github.com/pulls?q=issues',
325-
'https://github.com/pulls/review-requested',
326-
'https://github.com/sindresorhus/refined-github/pulls',
327-
'https://github.com/sindresorhus/refined-github/pulls/',
328-
'https://github.com/sindresorhus/refined-github/pulls?q=is%3Aopen+is%3Apr',
329-
'https://github.com/sindresorhus/refined-github/pulls?q=is%3Apr+is%3Aclosed',
330-
]);
330+
export const isPRList = (url: URL | HTMLAnchorElement | Location = location): boolean => isGlobalPRList(url) || isRepoPRList(url);
331+
TEST: addTests('isPRList', combinedTestOnly);
331332

332333
export const isPRCommit = (url: URL | HTMLAnchorElement | Location = location): boolean => /^pull\/\d+\/(commits|changes)\/[\da-f]{7,40}$/.test(getRepo(url)?.path);
333334
TEST: addTests('isPRCommit', [
@@ -459,7 +460,7 @@ TEST: addTests('isRepo', [
459460
// Some of these are here simply as "gotchas" to other detections
460461
'https://github.com/sindresorhus/refined-github/blame/master/package.json',
461462
'https://github.com/sindresorhus/refined-github/issues/146',
462-
'https://github.com/sindresorhus/notifications/',
463+
'https://github.com/sindresorhus/notifications/', // Gotcha for isNotifications
463464
'https://github.com/sindresorhus/refined-github/pull/148',
464465
'https://github.com/sindresorhus/refined-github/milestones/new', // Gotcha for isRepoTaxonomyIssueOrPRList
465466
'https://github.com/sindresorhus/refined-github/milestones/1/edit', // Gotcha for isRepoTaxonomyIssueOrPRList
@@ -792,6 +793,8 @@ TEST: addTests('isProfile', [
792793
'https://github.com/sindresorhus?tab=followers',
793794
'https://github.com/fregante?tab=following',
794795
'https://github.com/sindresorhus?tab=following',
796+
'https://github.com/pullsuser', // Gotcha for isGlobalPRList
797+
'https://github.com/issuesuser', // Gotcha for isGlobalIssueList
795798
]);
796799

797800
export const isGistProfile = (url: URL | HTMLAnchorElement | Location = location): boolean => doesLookLikeAProfile(getCleanGistPathname(url));

0 commit comments

Comments
 (0)