File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -189,6 +189,8 @@ collect.set('isPRCommit', [
189
189
'https://github.com/sindresorhus/refined-github/pull/148/commits/00196' ,
190
190
] ) ;
191
191
192
+ export const isPRCommit404 = ( ) : boolean => isPRCommit ( ) && document . title . startsWith ( 'Commit range not found · Pull Request' ) ;
193
+
192
194
export const isPRConversation = ( url : URL | Location = location ) : boolean => / ^ p u l l \/ \d + $ / . test ( getRepoPath ( url ) ! ) ;
193
195
collect . set ( 'isPRConversation' , [
194
196
'https://github.com/sindresorhus/refined-github/pull/148' ,
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import collector from './collector';
7
7
const { window} = new JSDOM ( '…' ) ;
8
8
9
9
( global as any ) . document = window . document ;
10
+ ( global as any ) . location = new URL ( 'https://github.com/' ) ;
10
11
11
12
const allUrls = new Set < string > ( [ ...collector . values ( ) ] . flat ( ) ) ;
12
13
allUrls . delete ( 'combinedTestOnly' ) ;
@@ -96,6 +97,20 @@ test('is500', t => {
96
97
t . false ( pageDetect . is500 ( ) ) ;
97
98
} ) ;
98
99
100
+ test ( 'isPRCommit404' , t => {
101
+ document . title = 'Commit range not found · Pull Request #3227 · sindresorhus/refined-github' ;
102
+ location . href = 'https://github.com/sindresorhus/refined-github/pull/3227/commits/32c8a88360a85739f151566eae0225d530ce6a15' ;
103
+ t . true ( pageDetect . isPRCommit404 ( ) ) ;
104
+
105
+ document . title = 'Experiment with `@primer/octicons-react` icons by FloEdelmann · Pull Request #3227 · sindresorhus/refined-github' ;
106
+ location . href = 'https://github.com/sindresorhus/refined-github/pull/3227/commits/edbdcdd5559a2a8da78abdc7cb0814155713974c' ;
107
+ t . false ( pageDetect . isPRCommit404 ( ) ) ;
108
+
109
+ document . title = 'Commit range not found by SomeContributor · Pull Request #999999 · sindresorhus/refined-github' ;
110
+ location . href = 'https://github.com/sindresorhus/refined-github/pull/999999/commits/32c8a88360a85739f151566eae0225d530ce6a15' ;
111
+ t . false ( pageDetect . isPRCommit404 ( ) ) ;
112
+ } ) ;
113
+
99
114
test ( 'getRepoPath' , t => {
100
115
const pairs = new Map < string , string | undefined > ( [
101
116
[
You can’t perform that action at this time.
0 commit comments