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', [
189189 'https://github.com/sindresorhus/refined-github/pull/148/commits/00196' ,
190190] ) ;
191191
192+ export const isPRCommit404 = ( ) : boolean => isPRCommit ( ) && document . title . startsWith ( 'Commit range not found · Pull Request' ) ;
193+
192194export const isPRConversation = ( url : URL | Location = location ) : boolean => / ^ p u l l \/ \d + $ / . test ( getRepoPath ( url ) ! ) ;
193195collect . set ( 'isPRConversation' , [
194196 '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';
77const { window} = new JSDOM ( '…' ) ;
88
99( global as any ) . document = window . document ;
10+ ( global as any ) . location = new URL ( 'https://github.com/' ) ;
1011
1112const allUrls = new Set < string > ( [ ...collector . values ( ) ] . flat ( ) ) ;
1213allUrls . delete ( 'combinedTestOnly' ) ;
@@ -96,6 +97,20 @@ test('is500', t => {
9697 t . false ( pageDetect . is500 ( ) ) ;
9798} ) ;
9899
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+
99114test ( 'getRepoPath' , t => {
100115 const pairs = new Map < string , string | undefined > ( [
101116 [
You can’t perform that action at this time.
0 commit comments