Skip to content

Commit a34106b

Browse files
authored
Include isPRCommit in isPRFiles (#180)
1 parent 3c87228 commit a34106b

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

index.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ export const isCommit = (url: URL | HTMLAnchorElement | Location = location): bo
2828
addTests('isCommit', [
2929
'https://github.com/sindresorhus/refined-github/commit/5b614b9035f2035b839f48b4db7bd5c3298d526f',
3030
'https://github.com/sindresorhus/refined-github/commit/5b614',
31-
'https://github.com/sindresorhus/refined-github/pull/148/commits/0019603b83bd97c2f7ef240969f49e6126c5ec85',
32-
'https://github.com/sindresorhus/refined-github/pull/148/commits/00196',
31+
'isPRCommit',
3332
]);
3433

3534
export const isCommitList = (url: URL | HTMLAnchorElement | Location = location): boolean => isRepoCommitList(url) || isPRCommitList(url);
@@ -229,11 +228,9 @@ addTests('isDiscussionList', [
229228

230229
export const isPR = (url: URL | HTMLAnchorElement | Location = location): boolean => /^pull\/\d+/.test(getRepo(url)?.path!) && !isPRConflicts(url);
231230
addTests('isPR', [
231+
'isPRFiles',
232+
'isPRCommitList',
232233
'https://github.com/sindresorhus/refined-github/pull/148',
233-
'https://github.com/sindresorhus/refined-github/pull/148/commits',
234-
'https://github.com/sindresorhus/refined-github/pull/148/files',
235-
'https://github.com/sindresorhus/refined-github/pull/148/commits/00196',
236-
'https://github.com/sindresorhus/refined-github/pull/148/commits/0019603b83bd97c2f7ef240969f49e6126c5ec85',
237234
]);
238235

239236
export const isPRConflicts = (url: URL | HTMLAnchorElement | Location = location): boolean => /^pull\/\d+\/conflicts/.test(getRepo(url)?.path!);
@@ -271,9 +268,12 @@ addTests('isPRCommitList', [
271268
'https://github.com/sindresorhus/refined-github/pull/148/commits',
272269
]);
273270

274-
export const isPRFiles = (url: URL | HTMLAnchorElement | Location = location): boolean => /^pull\/\d+\/files/.test(getRepo(url)?.path!);
271+
export const isPRFiles = (url: URL | HTMLAnchorElement | Location = location): boolean => /^pull\/\d+\/files/.test(getRepo(url)?.path!) || isPRCommit(url);
275272
addTests('isPRFiles', [
273+
'isPRCommit', // File contents but lacks "Viewed" checkbox, has commit information
276274
'https://github.com/sindresorhus/refined-github/pull/148/files',
275+
'https://github.com/sindresorhus/refined-github/pull/148/files/e1aba6f', // This means "every commit until e1aba6f"
276+
'https://github.com/sindresorhus/refined-github/pull/148/files/1e27d799..e1aba6f', // This means specifically "Between commit A and B"
277277
]);
278278

279279
export const isQuickPR = (url: URL | HTMLAnchorElement | Location = location): boolean => isCompare(url) && /[?&]quick_pull=1(&|$)/.test(url.search);

0 commit comments

Comments
 (0)