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', [
528528 'https://github.com/sindresorhus/refined-github/find/master' ,
529529] ) ;
530530
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+
531537export const isRepoForksList = ( url : URL | HTMLAnchorElement | Location = location ) : boolean => getRepo ( url ) ?. path === 'network/members' ;
532538addTests ( 'isRepoForksList' , [
533539 '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 => {
129129 t . false ( pageDetect . isPRFile404 ( ) ) ;
130130} ) ;
131131
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+
132142const { getRepositoryInfo} = pageDetect . utils ;
133143test ( 'getRepositoryInfo' , t => {
134144 const inputTypes = [
You can’t perform that action at this time.
0 commit comments