Skip to content

Commit 7b44eb5

Browse files
authored
Add isReleases and isTags (#103)
1 parent ca4edcf commit 7b44eb5

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

index.ts

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -253,14 +253,31 @@ export const isOpenPR = (): boolean => exists('#partial-discussion-header [title
253253
export const isMergedPR = (): boolean => exists('#partial-discussion-header [title="Status: Merged"]');
254254
export const isClosedPR = (): boolean => exists('#partial-discussion-header [title="Status: Closed"], #partial-discussion-header [title="Status: Merged"]');
255255

256-
export const isReleasesOrTags = (url: URL | HTMLAnchorElement | Location = location): boolean => /^tags$|^releases($|\/tag)/.test(getRepo(url)?.path!);
257-
collect.set('isReleasesOrTags', [
256+
export const isReleases = (url: URL | HTMLAnchorElement | Location = location): boolean => getRepo(url)?.path === 'releases';
257+
collect.set('isReleases', [
258258
'https://github.com/sindresorhus/refined-github/releases',
259+
'https://github.com/sindresorhus/refined-github/releases?page=2',
260+
]);
261+
262+
export const isTags = (url: URL | HTMLAnchorElement | Location = location): boolean => getRepo(url)?.path === 'tags';
263+
collect.set('isTags', [
259264
'https://github.com/sindresorhus/refined-github/tags',
265+
'https://github.com/sindresorhus/refined-github/tags?after=21.8.1',
266+
]);
267+
268+
export const isSingleTag = (url: URL | HTMLAnchorElement | Location = location): boolean => /^(releases\/tag)/.test(getRepo(url)?.path!);
269+
collect.set('isSingleTag', [
260270
'https://github.com/sindresorhus/refined-github/releases/tag/v1.0.0-beta.4',
261271
'https://github.com/sindresorhus/refined-github/releases/tag/0.2.1',
262272
]);
263273

274+
export const isReleasesOrTags = (url: URL | HTMLAnchorElement | Location = location): boolean => isReleases(url) || isTags(url) || isSingleTag(url);
275+
collect.set('isReleasesOrTags', [
276+
...collect.get('isReleases') as string[],
277+
...collect.get('isTags') as string[],
278+
...collect.get('isSingleTag') as string[],
279+
]);
280+
264281
export const isDeletingFile = (url: URL | HTMLAnchorElement | Location = location): boolean => Boolean(getRepo(url)?.path.startsWith('delete'));
265282
collect.set('isDeletingFile', [
266283
'https://github.com/sindresorhus/refined-github/delete/master/readme.md',
@@ -540,12 +557,6 @@ collect.set('isUserProfileFollowingTab', [
540557
'https://github.com/sindresorhus?tab=following',
541558
]);
542559

543-
export const isSingleTag = (url: URL | HTMLAnchorElement | Location = location): boolean => /^(releases\/tag)/.test(getRepo(url)?.path!);
544-
collect.set('isSingleTag', [
545-
'https://github.com/sindresorhus/refined-github/releases/tag/v1.0.0-beta.4',
546-
'https://github.com/sindresorhus/refined-github/releases/tag/0.2.1',
547-
]);
548-
549560
collect.set('hasComments', combinedTestOnly);
550561
export const hasComments = (url: URL | HTMLAnchorElement | Location = location): boolean =>
551562
isPR(url)

0 commit comments

Comments
 (0)