File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -528,6 +528,12 @@ addTests('isFileFinder', [
528
528
'https://github.com/sindresorhus/refined-github/find/master' ,
529
529
] ) ;
530
530
531
+ /**
532
+ * @example https://github.com/fregante/GhostText/tree/3cacd7df71b097dc525d99c7aa2f54d31b02fcc8/chrome/scripts/InputArea
533
+ * @example https://github.com/refined-github/refined-github/blob/some-non-existent-ref/source/features/bugs-tab.tsx
534
+ */
535
+ export const isRepoFile404 = ( url : URL | HTMLAnchorElement | Location = location ) : boolean => ( isSingleFile ( url ) || isRepoTree ( url ) ) && document . title . startsWith ( 'File not found' ) ;
536
+
531
537
export const isRepoForksList = ( url : URL | HTMLAnchorElement | Location = location ) : boolean => getRepo ( url ) ?. path === 'network/members' ;
532
538
addTests ( 'isRepoForksList' , [
533
539
'https://github.com/sindresorhus/refined-github/network/members' ,
Original file line number Diff line number Diff line change @@ -129,6 +129,16 @@ test('isPRFile404', t => {
129
129
t . false ( pageDetect . isPRFile404 ( ) ) ;
130
130
} ) ;
131
131
132
+ test ( 'isRepoFile404' , t => {
133
+ document . title = 'File not found' ;
134
+ location . href = 'https://github.com/fregante/GhostText/tree/3cacd7df71b097dc525d99c7aa2f54d31b02fcc8/chrome/scripts/InputArea' ;
135
+ t . true ( pageDetect . isRepoFile404 ( ) ) ;
136
+
137
+ document . title = 'File not found' ;
138
+ location . href = 'https://github.com/refined-github/refined-github/blob/some-non-existent-ref/source/features/bugs-tab.tsx' ;
139
+ t . true ( pageDetect . isRepoFile404 ( ) ) ;
140
+ } ) ;
141
+
132
142
const { getRepositoryInfo} = pageDetect . utils ;
133
143
test ( 'getRepositoryInfo' , t => {
134
144
const inputTypes = [
You can’t perform that action at this time.
0 commit comments